diff options
author | Sven Gothel <[email protected]> | 2012-11-08 18:07:19 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-11-08 18:07:19 +0100 |
commit | d0f91a8ed17fbb1a7b56511c4e53a29e576f01af (patch) | |
tree | 3e3f906f794ba1abe340190a4dfac12dadf5c921 /src/jogl/classes/com | |
parent | 9ce042df68b70a0e62b21b93d2a1a64722e1e49e (diff) |
Fix GLAutoDrawable.dispose(): Dispose drawable even w/o context; JAWTWindow.lockSurface(): Check AWT component's native peer
- Fix GLAutoDrawable.dispose(): Dispose drawable even w/o context
- It is possible to have the GLContext not being created (not made current),
so drawable shall be disposed independent.
- Merge Runnable 'postDisposeOnEDTAction' to dispose Runnable for clarity
- GLDrawableHelper: Split disposeGL from invokeGLImpl for clarity
- JAWTWindow.lockSurface(): Check AWT component's native peer
- W/o a native peer (!isDisplayable()), JAWT locking cannot succeed.
- On OSX OpenJDK 1.7, attempting to JAWT lock a peer-less component crashes the VM
- MacOSXJAWTWindow.lockSurfaceImpl(): Remove redundant null checks
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 755a7c392..e80079c20 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -173,45 +173,49 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* * Disposes of OpenGL resources */ - private final Runnable postDisposeGLAction = new Runnable() { - @Override - public void run() { - context = null; - if (null != drawable) { - drawable.setRealized(false); - drawable = null; - } - } - }; - private final Runnable disposeOnEDTGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; _lock.lock(); try { - if (null != drawable && null != context) { - boolean animatorPaused = false; - final GLAnimatorControl animator = getAnimator(); - if (null != animator) { - animatorPaused = animator.pause(); - } - - if(context.isCreated()) { - helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); - } - - if (animatorPaused) { - animator.resume(); - } + final GLAnimatorControl animator = getAnimator(); + final boolean animatorPaused; + if(null!=animator) { + // can't remove us from animator for recreational addNotify() + animatorPaused = animator.pause(); + } else { + animatorPaused = false; + } + + if ( null != context ) { + if( context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(GLCanvas.this, context); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + context = null; + } + if ( null != drawable ) { + drawable.setRealized(false); + drawable = null; } // SWT is owner of the device handle, not us. // Hence close() operation is a NOP. if (null != device) { - device.close(); - device = null; + device.close(); + device = null; } SWTAccessor.setRealized(GLCanvas.this, false); // unrealize .. + + if (animatorPaused) { + animator.resume(); + } + } finally { _lock.unlock(); } |