multiple sketches running at once again (issue #567)

This commit is contained in:
benfry
2011-04-16 20:51:10 +00:00
parent 708bf83f1d
commit 225793baee
3 changed files with 24 additions and 11 deletions

View File

@@ -478,7 +478,8 @@ public class JavaEditor extends Editor {
public void run() {
prepareRun();
try {
jmode.handleRun(sketch, JavaEditor.this);
runtime = jmode.handleRun(sketch, JavaEditor.this);
// System.out.println("runtime now " + runtime);
} catch (Exception e) {
statusError(e);
}
@@ -494,7 +495,7 @@ public class JavaEditor extends Editor {
public void run() {
prepareRun();
try {
jmode.handlePresent(sketch, JavaEditor.this);
runtime = jmode.handlePresent(sketch, JavaEditor.this);
} catch (Exception e) {
statusError(e);
}
@@ -510,7 +511,9 @@ public class JavaEditor extends Editor {
//jmode.handleStop();
if (runtime != null) {
runtime.close(); // kills the window
runtime = null; // will this help?
runtime = null;
// } else {
// System.out.println("runtime is null");
}
} catch (Exception e) {
statusError(e);

View File

@@ -172,26 +172,34 @@ public class JavaMode extends Mode {
public Runner handleRun(Sketch sketch, RunnerListener listener) throws SketchException {
Runner runtime = null;
JavaBuild build = new JavaBuild(sketch);
String appletClassName = build.build();
if (appletClassName != null) {
runtime = new Runner(build, listener);
runtime.launch(false);
final Runner runtime = new Runner(build, listener);
new Thread(new Runnable() {
public void run() {
runtime.launch(false); // this blocks until finished
}
}).start();
return runtime;
}
return runtime;
return null;
}
public Runner handlePresent(Sketch sketch, RunnerListener listener) throws SketchException {
Runner runtime = null;
JavaBuild build = new JavaBuild(sketch);
String appletClassName = build.build();
if (appletClassName != null) {
runtime = new Runner(build, listener);
runtime.launch(true);
final Runner runtime = new Runner(build, listener);
new Thread(new Runnable() {
public void run() {
runtime.launch(true);
}
}).start();
return runtime;
}
return runtime;
return null;
}