diff options
Diffstat (limited to 'src/jogl')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/Animator.java | 36 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLException.java | 6 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLDrawableHelper.java | 11 |
3 files changed, 47 insertions, 6 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index ae09d81a4..634e83353 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -132,6 +132,8 @@ public class Animator extends AnimatorBase { @Override public void run() { + GLException displayCaught = null; + try { synchronized (Animator.this) { if(DEBUG) { @@ -158,7 +160,14 @@ public class Animator extends AnimatorBase { if ( exclusiveContext && !drawablesEmpty && !ectCleared ) { ectCleared = true; setDrawablesExclCtxState(false); - display(); // propagate exclusive change! + try { + display(); // propagate exclusive change! + } catch (final Throwable t) { + displayCaught = GLException.newGLException(t); + stopIssued = true; + isAnimating = false; + break; // end pause loop + } } isAnimating = false; Animator.this.notifyAll(); @@ -185,7 +194,14 @@ public class Animator extends AnimatorBase { } } // sync Animator.this if (!stopIssued) { - display(); + try { + display(); + } catch (final Throwable t) { + displayCaught = GLException.newGLException(t); + stopIssued = true; + isAnimating = false; + break; // end animation loop + } } if (!stopIssued && !runAsFastAsPossible) { // Avoid swamping the CPU @@ -201,16 +217,32 @@ public class Animator extends AnimatorBase { if( exclusiveContext && !drawablesEmpty ) { setDrawablesExclCtxState(false); display(); // propagate exclusive change! + try { + display(); // propagate exclusive change! + } catch (final Throwable t) { + if( null == displayCaught ) { + displayCaught = GLException.newGLException(t); + } else { + GLException.newGLException(t).printStackTrace(); + } + } } synchronized (Animator.this) { if(DEBUG) { System.err.println("Animator stop on " + animThread.getName() + ": " + toString()); + if( null != displayCaught ) { + System.err.println("Animator caught: "+displayCaught.getMessage()); + displayCaught.printStackTrace(); + } } stopIssued = false; pauseIssued = false; animThread = null; isAnimating = false; Animator.this.notifyAll(); + if( null != displayCaught ) { + throw displayCaught; + } } } } diff --git a/src/jogl/classes/javax/media/opengl/GLException.java b/src/jogl/classes/javax/media/opengl/GLException.java index 15e9cddac..dff9b9dad 100644 --- a/src/jogl/classes/javax/media/opengl/GLException.java +++ b/src/jogl/classes/javax/media/opengl/GLException.java @@ -66,8 +66,10 @@ public class GLException extends RuntimeException { super(cause); } - /** Constructs a GLException object with the specified root - cause with a decorating message including the current thread name. */ + /** + * Constructs a GLException object with the specified root + * cause with a decorating message including the current thread name. + */ public static GLException newGLException(final Throwable t) { return new GLException("Caught "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName(), t); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 6462b801b..945ca5479 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -551,6 +551,7 @@ public class GLDrawableHelper { } } if( null != firstCaught ) { + flushGLRunnables(); throw GLException.newGLException(firstCaught); } return disposeCount; @@ -658,7 +659,7 @@ public class GLDrawableHelper { init( listener, drawable, sendReshape, 0==i /* setViewport */); } } else { - // Expose same GL initialization if not using GLEventListener + // Expose same GL initialization if not using any GLEventListener drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); } } @@ -1067,6 +1068,7 @@ public class GLDrawableHelper { try { forceNativeRelease(context); } catch (final Throwable ex) { + flushGLRunnables(); throw GLException.newGLException(ex); } } @@ -1193,11 +1195,12 @@ public class GLDrawableHelper { } else { forceNativeRelease(context); } - flushGLRunnables(); } catch (final Throwable t) { GLException.dumpThrowable(t); contextCloseCaught = t; } + flushGLRunnables(); // always flush GLRunnables at dispose + if (lastContext != null) { final int res2 = lastContext.makeCurrent(); if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { @@ -1307,9 +1310,11 @@ public class GLDrawableHelper { } } if( null != glEventListenerCaught ) { + flushGLRunnables(); throw GLException.newGLException(glEventListenerCaught); } if( null != contextReleaseCaught ) { + flushGLRunnables(); throw GLException.newGLException(contextReleaseCaught); } } @@ -1426,9 +1431,11 @@ public class GLDrawableHelper { } } if( null != glEventListenerCaught ) { + flushGLRunnables(); throw GLException.newGLException(glEventListenerCaught); } if( null != contextReleaseCaught ) { + flushGLRunnables(); throw GLException.newGLException(contextReleaseCaught); } } |