merged master and resolved conflicts

This commit is contained in:
voidplus
2014-11-15 08:33:11 +01:00
57 changed files with 964 additions and 491 deletions

View File

@@ -131,12 +131,12 @@ public class Compiler {
// so that it can grab the compiler JAR files from it.
ClassLoader loader = build.mode.getClassLoader();
try {
Class batchClass =
Class<?> batchClass =
Class.forName("org.eclipse.jdt.core.compiler.batch.BatchCompiler", false, loader);
Class progressClass =
Class<?> progressClass =
Class.forName("org.eclipse.jdt.core.compiler.CompilationProgress", false, loader);
Class[] compileArgs =
new Class[] { String[].class, PrintWriter.class, PrintWriter.class, progressClass };
Class<?>[] compileArgs =
new Class<?>[] { String[].class, PrintWriter.class, PrintWriter.class, progressClass };
Method compileMethod = batchClass.getMethod("compile", compileArgs);
success = (Boolean)
compileMethod.invoke(null, new Object[] { command, outWriter, writer, null });

View File

@@ -80,6 +80,7 @@ public class PdeKeyListener {
Sketch sketch = editor.getSketch();
/*
if ((event.getModifiers() & CTRL_ALT) == CTRL_ALT) {
if (code == KeyEvent.VK_LEFT) {
sketch.handlePrevCode();
@@ -89,6 +90,7 @@ public class PdeKeyListener {
return true;
}
}
*/
if ((event.getModifiers() & InputEvent.META_MASK) != 0) {
//event.consume(); // does nothing

View File

@@ -49,11 +49,6 @@ public class PresentMode {
//JMenu preferencesMenu;
static JComboBox selector;
/**
* Index of the currently selected display to be used for present mode.
*/
static GraphicsDevice device;
static {
GraphicsEnvironment environment =
@@ -75,7 +70,6 @@ public class PresentMode {
selector.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int index = selector.getSelectedIndex();
//device = devices[index];
Preferences.setInteger("run.present.display", index + 1);
}
});

View File

@@ -67,6 +67,9 @@ public class Runner implements MessageConsumer {
protected Editor editor;
protected JavaBuild build;
protected Process process;
protected PrintStream sketchErr;
protected PrintStream sketchOut;
public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
@@ -76,15 +79,18 @@ public class Runner implements MessageConsumer {
if (listener instanceof Editor) {
this.editor = (Editor) listener;
// } else {
// System.out.println("actually it's a " + listener.getClass().getName());
sketchErr = editor.getConsole().getErr();
sketchOut = editor.getConsole().getOut();
} else {
sketchErr = System.err;
sketchOut = System.out;
}
// Make sure all the imported libraries will actually run with this setup.
int bits = Base.getNativeBits();
for (Library library : build.getImportedLibraries()) {
if (!library.supportsArch(PApplet.platform, bits)) {
System.err.println(library.getName() + " does not run in " + bits + "-bit mode.");
sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode.");
int opposite = (bits == 32) ? 64 : 32;
if (Base.isMacOS()) {
//if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true
@@ -173,7 +179,7 @@ public class Runner implements MessageConsumer {
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
e1.printStackTrace();
e1.printStackTrace(sketchErr);
}
}
}
@@ -388,18 +394,18 @@ public class Runner implements MessageConsumer {
"Preferences window. For more information, read Help \u2192 Troubleshooting.", null);
} else {
for (String err : errorStrings) {
System.err.println(err);
sketchErr.println(err);
}
System.err.println("Using startup command: " + PApplet.join(args, " "));
sketchErr.println("Using startup command: " + PApplet.join(args, " "));
}
} else {
//exc.printStackTrace();
System.err.println("Could not run the sketch (Target VM failed to initialize).");
sketchErr.println("Could not run the sketch (Target VM failed to initialize).");
if (Preferences.getBoolean("run.options.memory")) {
// Only mention this if they've even altered the memory setup
System.err.println("Make sure that you haven't set the maximum available memory too high.");
sketchErr.println("Make sure that you haven't set the maximum available memory too high.");
}
System.err.println("For more information, read revisions.txt and Help \u2192 Troubleshooting.");
sketchErr.println("For more information, read revisions.txt and Help \u2192 Troubleshooting.");
}
// changing this to separate editor and listener [091124]
//if (editor != null) {
@@ -491,7 +497,7 @@ public class Runner implements MessageConsumer {
outThread = new StreamRedirectThread("JVM stdout Reader",
process.getInputStream(),
System.out);
sketchOut);
errThread.start();
outThread.start();
@@ -578,7 +584,7 @@ public class Runner implements MessageConsumer {
// First just report the exception and its placement
reportException(message, or, event.thread());
// Then try to pretty it up with a better message
handleCommonErrors(exceptionName, message, listener);
handleCommonErrors(exceptionName, message, listener, sketchErr);
if (editor != null) {
editor.deactivateRun();
@@ -598,41 +604,42 @@ public class Runner implements MessageConsumer {
*/
public static boolean handleCommonErrors(final String exceptionClass,
final String message,
final RunnerListener listener) {
final RunnerListener listener,
final PrintStream err) {
if (exceptionClass.equals("java.lang.OutOfMemoryError")) {
if (message.contains("exceeds VM budget")) {
// TODO this is a kludge for Android, since there's no memory preference
listener.statusError("OutOfMemoryError: This code attempts to use more memory than available.");
System.err.println("An OutOfMemoryError means that your code is either using up too much memory");
System.err.println("because of a bug (e.g. creating an array that's too large, or unintentionally");
System.err.println("loading thousands of images), or simply that it's trying to use more memory");
System.err.println("than what is supported by the current device.");
err.println("An OutOfMemoryError means that your code is either using up too much memory");
err.println("because of a bug (e.g. creating an array that's too large, or unintentionally");
err.println("loading thousands of images), or simply that it's trying to use more memory");
err.println("than what is supported by the current device.");
} else {
listener.statusError("OutOfMemoryError: You may need to increase the memory setting in Preferences.");
System.err.println("An OutOfMemoryError means that your code is either using up too much memory");
System.err.println("because of a bug (e.g. creating an array that's too large, or unintentionally");
System.err.println("loading thousands of images), or that your sketch may need more memory to run.");
System.err.println("If your sketch uses a lot of memory (for instance if it loads a lot of data files)");
System.err.println("you can increase the memory available to your sketch using the Preferences window.");
err.println("An OutOfMemoryError means that your code is either using up too much memory");
err.println("because of a bug (e.g. creating an array that's too large, or unintentionally");
err.println("loading thousands of images), or that your sketch may need more memory to run.");
err.println("If your sketch uses a lot of memory (for instance if it loads a lot of data files)");
err.println("you can increase the memory available to your sketch using the Preferences window.");
}
} else if (exceptionClass.equals("java.lang.UnsatisfiedLinkError")) {
listener.statusError("A library used by this sketch is not installed properly.");
System.err.println("A library relies on native code that's not available.");
System.err.println("Or only works properly when the sketch is run as a " +
err.println("A library relies on native code that's not available.");
err.println("Or only works properly when the sketch is run as a " +
((Base.getNativeBits() == 32) ? "64-bit " : "32-bit ") + " application.");
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
listener.statusError("StackOverflowError: This sketch is attempting too much recursion.");
System.err.println("A StackOverflowError means that you have a bug that's causing a function");
System.err.println("to be called recursively (it's calling itself and going in circles),");
System.err.println("or you're intentionally calling a recursive function too much,");
System.err.println("and your code should be rewritten in a more efficient manner.");
err.println("A StackOverflowError means that you have a bug that's causing a function");
err.println("to be called recursively (it's calling itself and going in circles),");
err.println("or you're intentionally calling a recursive function too much,");
err.println("and your code should be rewritten in a more efficient manner.");
} else if (exceptionClass.equals("java.lang.UnsupportedClassVersionError")) {
listener.statusError("UnsupportedClassVersionError: A library is using code compiled with an unsupported version of Java.");
System.err.println("This version of Processing only supports libraries and JAR files compiled for Java 1.6 or earlier.");
System.err.println("A library used by this sketch was compiled for Java 1.7 or later, ");
System.err.println("and needs to be recompiled to be compatible with Java 1.6.");
err.println("This version of Processing only supports libraries and JAR files compiled for Java 1.6 or earlier.");
err.println("A library used by this sketch was compiled for Java 1.7 or later, ");
err.println("and needs to be recompiled to be compatible with Java 1.6.");
} else if (exceptionClass.equals("java.lang.NoSuchMethodError") ||
exceptionClass.equals("java.lang.NoSuchFieldError")) {
@@ -692,7 +699,7 @@ public class Runner implements MessageConsumer {
} catch (IncompatibleThreadStateException e) {
// This shouldn't happen, but if it does, print the exception in case
// it's something that needs to be debugged separately.
e.printStackTrace();
e.printStackTrace(sketchErr);
}
// before giving up, try to extract from the throwable object itself
// since sometimes exceptions are re-thrown from a different context
@@ -724,7 +731,7 @@ public class Runner implements MessageConsumer {
or.invokeMethod(thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(sketchErr);
}
// Give up, nothing found inside the pile of stack frames
SketchException rex = new SketchException(message);
@@ -795,8 +802,8 @@ public class Runner implements MessageConsumer {
// always shove out the message, since it might not fall under
// the same setup as we're expecting
System.err.print(s);
sketchErr.print(s);
//System.err.println("[" + s.length() + "] " + s);
System.err.flush();
sketchErr.flush();
}
}