fixes for running applet as external vm

This commit is contained in:
benfry
2003-09-26 19:06:22 +00:00
parent 11a030bba6
commit 4f5f7e994c
3 changed files with 84 additions and 32 deletions
+17 -7
View File
@@ -798,11 +798,15 @@ public class PdeEditor extends JPanel {
public void run() {
while (Thread.currentThread() == thread) {
if ((runtime != null) && (runtime.applet != null)) {
//System.out.println(runtime.applet.finished);
buttons.running(!runtime.applet.finished);
//} else {
//System.out.println("still pooping");
if (runtime != null) {
if (runtime.applet != null) {
//System.out.println(runtime.applet.finished);
buttons.running(!runtime.applet.finished);
//} else {
//System.out.println("still pooping");
} else if (runtime.process != null) {
buttons.running(true); // ??
}
}
try {
Thread.sleep(250);
@@ -811,7 +815,9 @@ public class PdeEditor extends JPanel {
}
public void stop() {
thread.stop();
buttons.running(false);
thread = null;
//thread.stop();
}
}
@@ -1551,7 +1557,11 @@ public class PdeEditor extends JPanel {
public void doQuit() {
doStop();
// stop isn't sufficient with external vm & quit
// instead use doClose() which will kill the external vm
//doStop();
doClose();
//if (!checkModified()) return;
checkModified(DO_QUIT);
//System.out.println("exiting doquit");
+42 -13
View File
@@ -37,7 +37,6 @@ import gnu.io.*;
public class PdeRuntime implements PdeMessageConsumer {
Process process;
BApplet applet;
PdeException exception;
Window window;
@@ -48,6 +47,8 @@ public class PdeRuntime implements PdeMessageConsumer {
boolean newMessage;
int messageLineCount;
Process process;
OutputStream processOutput;
boolean externalRuntime;
String externalPaths;
@@ -85,13 +86,14 @@ public class PdeRuntime implements PdeMessageConsumer {
"-cp",
externalPaths,
"BApplet",
"--location=" + x1 + "," + y1,
"--external=" + x1 + "," + y1,
className
};
process = Runtime.getRuntime().exec(command);
new PdeMessageSiphon(process.getInputStream(), this);
new PdeMessageSiphon(process.getErrorStream(), this);
processOutput = process.getOutputStream();
} else {
Class c = Class.forName(className);
@@ -305,23 +307,33 @@ public class PdeRuntime implements PdeMessageConsumer {
public void stop() {
//System.out.println();
//System.out.println("* stopping");
//System.out.println("PdeRuntime.stop()");
// check for null in case stop is called during compilation
if (applet != null) applet.stop();
//if (window != null) window.hide();
if (applet != null) {
applet.stop();
//if (window != null) window.hide();
// above avoids NullPointerExceptions
// but still threading is too complex, and so
// some boogers are being left behind
// above avoids NullPointerExceptions
// but still threading is too complex, and so
// some boogers are being left behind
applet = null;
//window = null;
applet = null;
//window = null;
if (process != null) { // running externally
} else if (process != null) { // running externally
//System.out.println("killing external process");
process.destroy();
process = null;
try {
//System.out.println("writing to stop process");
processOutput.write('s');
processOutput.flush();
} catch (IOException e) {
System.err.println("error stopping external applet");
e.printStackTrace();
close();
}
/*
try {
@@ -349,10 +361,27 @@ public class PdeRuntime implements PdeMessageConsumer {
window.dispose();
window = null;
}
if (process != null) {
try {
process.destroy();
} catch (Exception e) {
System.err.println("(ignored) error while destroying");
e.printStackTrace();
}
process = null;
}
}
public void message(String s) {
if (s.indexOf(BApplet.EXTERNAL_QUIT) == 0) {
//close();
System.out.println("got proper quit message");
editor.doClose();
return;
}
//System.err.println("message " + s.length() + ":" + s);
if (s.length() > 2) System.err.println(s);
+25 -12
View File
@@ -1,4 +1,27 @@
0063
X beautify menu became disabled when moved
X BImage(int width, int height) constructor
X trying to track down sluggishness with applets..
X beginShape/endShape.. 3D scenes with boxes..
X newPixels is in BGraphics.endFrame,
X screen.drawImage is in BApplet.paint
X need to move both to BApplet.paint()
_ external applet stuff
X set initial position of external applets via BApplet
_ send messages for window location
_ closing window doesn't disable the stop button
_ hitting 'stop' should freeze applet, not close window
_ what was the random NullPointerException
_ 'add files' for .class, .zip, .jar should drop the stuff in
_ jikes errors are missing newline/linefeed ?
_ using run-expert.bat on 62 causes NullPointerException weirdness
_ network/shared_canvas, network/value has old code
_ write script to remove .DS_Store and CVS folders from dist
_ include version number in the about box
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1064220242
assigned to dan haskovec, completed by fry
X for 'java' mode, try run using external vm
@@ -17,21 +40,11 @@ X or figure out how to unload old classes.. grr
X lockup when something missing from classpath on dynamic load
X but makes no error.. peditorconsole probably swallowing it
_ using run-expert.bat on 62 causes NullPointerException weirdness
_ ability to include other .java and .pde code from sketchbook folder
_ network/shared_canvas, network/value has old code
_ trying to track down sluggishness with applets..
_ beginShape/endShape.. 3D scenes with boxes..
_ write script to remove .DS_Store and CVS folders from dist
MEDIUM
_ include version number in the about box
_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1064220242
_ ability to include other .java and .pde code from sketchbook folder
_ 'add files' for .java or .pde pulls into the folder
_ light(x, y, z, c1, c2, c3, TYPE)
_ also BLight with same constructor, and on() and off() fxn
_ better 1.3/1.4 support.. properly detect vm