Change Editor status message only from EDT

This adapter invokes all status changes on the EDT instead of worker thread of the Runner. Modifying AWT components from the worker threads may introduce strange bugs and in this case caused UI changes to run out of order, hiding runtime exceptions under problems displayed when cursor moves to the offending line.
This commit is contained in:
Jakub Valtar
2018-04-24 11:31:27 +02:00
parent 0a31aa2b71
commit d29366d34b
3 changed files with 53 additions and 3 deletions

View File

@@ -39,6 +39,7 @@ import javax.swing.JTree; // needed for javadocs
import javax.swing.tree.DefaultMutableTreeNode;
import processing.app.Messages;
import processing.app.RunnerListenerEdtAdapter;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.mode.java.debug.*;
@@ -201,7 +202,7 @@ public class Debugger {
//lineMap = LineMapping.generateMapping(srcPath + File.separator + mainClassName + ".java");
log("launching debuggee runtime");
runtime = new Runner(build, editor);
runtime = new Runner(build, new RunnerListenerEdtAdapter(editor));
VirtualMachine vm = runtime.debug(null); // non-blocking
if (vm == null) {
loge("error 37: launch failed", null);

View File

@@ -1093,10 +1093,11 @@ public class JavaEditor extends Editor {
synchronized (runtimeLock) {
if (runtimeLaunchRequested) {
runtimeLaunchRequested = false;
RunnerListener listener = new RunnerListenerEdtAdapter(JavaEditor.this);
if (!tweak) {
runtime = jmode.handleLaunch(sketch, JavaEditor.this, present);
runtime = jmode.handleLaunch(sketch, listener, present);
} else {
runtime = jmode.handleTweak(sketch, JavaEditor.this);
runtime = jmode.handleTweak(sketch, listener);
}
}
}