From 4c445f6f993ee62fa41f8e897cce03303a94ecba Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 18 May 2015 11:09:10 -0400 Subject: [PATCH 1/2] better exception handling, fixes #3293 --- core/src/processing/opengl/PSurfaceJOGL.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index f7d03c4e9..19963b1b0 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -268,10 +268,13 @@ public class PSurfaceJOGL implements PSurface { e.printStackTrace(); } // System.err.println("Caught exception: " + drawException.getMessage()); - if (drawException instanceof RuntimeException) { - throw (RuntimeException)drawException.getCause(); - } else { - throw new RuntimeException(drawException.getCause()); + if (drawException != null) { + Throwable cause = drawException.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException)cause; + } else if (!(cause instanceof java.lang.ThreadDeath)) { + throw new RuntimeException(cause); + } } } } From 26a3c9c6ed9479c0823391b74bc5e2bc0e886e77 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 18 May 2015 11:35:28 -0400 Subject: [PATCH 2/2] separate case for ThreadDeath --- core/src/processing/opengl/PSurfaceJOGL.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index 19963b1b0..ad4dfe3b1 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -270,9 +270,12 @@ public class PSurfaceJOGL implements PSurface { // System.err.println("Caught exception: " + drawException.getMessage()); if (drawException != null) { Throwable cause = drawException.getCause(); - if (cause instanceof RuntimeException) { + if (cause instanceof ThreadDeath) { + System.out.println("caught ThreadDeath"); +// throw (ThreadDeath)cause; + } else if (cause instanceof RuntimeException) { throw (RuntimeException)cause; - } else if (!(cause instanceof java.lang.ThreadDeath)) { + } else { throw new RuntimeException(cause); } } @@ -511,7 +514,6 @@ public class PSurfaceJOGL implements PSurface { public void requestFocus() { window.requestFocus(); - } class DrawListener implements GLEventListener {