Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Created March 11, 2009 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/77302 to your computer and use it in GitHub Desktop.
Save jashkenas/77302 to your computer and use it in GitHub Desktop.
Index: core/src/processing/core/PApplet.java
===================================================================
--- core/src/processing/core/PApplet.java (revision 5371)
+++ core/src/processing/core/PApplet.java (working copy)
@@ -1386,7 +1386,22 @@
} catch (RendererChangeException e) {
// Give up, instead set the new renderer and re-attempt setup()
return;
+
+ // Catch a JRuby exception so that the RendererChangeExceptions
+ // that we're looking for don't get stuck in Ruby-space.
+ } catch (RuntimeException e) {
+ String message = e.getMessage();
+ String name = RendererChangeException.class.getName();
+ String regex = "(?s).*" + name + ".*";
+ regex = regex.replace("$", "\\$");
+ if (message != null && message.matches(regex)) {
+ // Give up, instead set the new renderer and re-attempt setup()
+ return;
+ } else {
+ throw e;
+ }
}
+
this.defaultSize = false;
} else { // frameCount > 0, meaning an actual draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment