Skip to content

Commit 4a50ea3

Browse files
committed
Small threading fixes for run/present/tweak
1 parent 7215447 commit 4a50ea3

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

java/src/processing/mode/java/JavaEditor.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,15 +1057,15 @@ public void handleRun() {
10571057
debugger.continueDebug();
10581058

10591059
} else {
1060+
prepareRun();
1061+
toolbar.activateRun();
10601062
new Thread(new Runnable() {
10611063
public void run() {
1062-
prepareRun();
10631064
try {
1064-
toolbar.activateRun();
10651065
//runtime = jmode.handleRun(sketch, JavaEditor.this);
10661066
runtime = jmode.handleLaunch(sketch, JavaEditor.this, false);
10671067
} catch (Exception e) {
1068-
statusError(e);
1068+
EventQueue.invokeLater(() -> statusError(e));
10691069
}
10701070
}
10711071
}).start();
@@ -1074,31 +1074,39 @@ public void run() {
10741074

10751075

10761076
public void handlePresent() {
1077+
prepareRun();
1078+
toolbar.activateRun();
10771079
new Thread(new Runnable() {
10781080
public void run() {
1079-
prepareRun();
10801081
try {
1081-
toolbar.activateRun();
10821082
//runtime = jmode.handlePresent(sketch, JavaEditor.this);
10831083
runtime = jmode.handleLaunch(sketch, JavaEditor.this, true);
10841084
} catch (Exception e) {
1085-
statusError(e);
1085+
EventQueue.invokeLater(() -> statusError(e));
10861086
}
10871087
}
10881088
}).start();
10891089
}
10901090

10911091

10921092
public void handleTweak() {
1093+
prepareRun();
1094+
//toolbar.activate(JavaToolbar.RUN);
1095+
toolbar.activateRun();
1096+
1097+
if (sketch.isModified()) {
1098+
toolbar.deactivateRun();
1099+
Messages.showMessage(Language.text("menu.file.save"),
1100+
Language.text("tweak_mode.save_before_tweak"));
1101+
return;
1102+
}
1103+
10931104
new Thread(new Runnable() {
10941105
public void run() {
1095-
prepareRun();
10961106
try {
1097-
// toolbar.activate(JavaToolbar.RUN);
1098-
toolbar.activateRun();
10991107
runtime = jmode.handleTweak(sketch, JavaEditor.this);
11001108
} catch (Exception e) {
1101-
statusError(e);
1109+
EventQueue.invokeLater(() -> statusError(e));
11021110
}
11031111
}
11041112
}).start();

java/src/processing/mode/java/JavaMode.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,6 @@ public Runner handleTweak(Sketch sketch,
144144
// final boolean present) throws SketchException {
145145
final JavaEditor editor = (JavaEditor) listener;
146146

147-
if (isSketchModified(sketch)) {
148-
editor.deactivateRun();
149-
Messages.showMessage(Language.text("menu.file.save"),
150-
Language.text("tweak_mode.save_before_tweak"));
151-
return null;
152-
}
153-
154147
// first try to build the unmodified code
155148
JavaBuild build = new JavaBuild(sketch);
156149
// String appletClassName = build.build(false);

0 commit comments

Comments
 (0)