diff options
Diffstat (limited to 'src/classes/javax/media/opengl/GLCanvas.java')
-rw-r--r-- | src/classes/javax/media/opengl/GLCanvas.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/classes/javax/media/opengl/GLCanvas.java b/src/classes/javax/media/opengl/GLCanvas.java index 0329e4017..d555a1df0 100644 --- a/src/classes/javax/media/opengl/GLCanvas.java +++ b/src/classes/javax/media/opengl/GLCanvas.java @@ -166,11 +166,19 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { <B>Overrides:</B> <DL><DD><CODE>removeNotify</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */ public void removeNotify() { - context.destroy(); - drawable.setRealized(false); - super.removeNotify(); - if (DEBUG) { - System.err.println("GLCanvas.removeNotify()"); + try { + if (Threading.isSingleThreaded() && + !Threading.isOpenGLThread()) { + Threading.invokeOnOpenGLThread(destroyAction); + } else { + context.destroy(); + } + } finally { + drawable.setRealized(false); + super.removeNotify(); + if (DEBUG) { + System.err.println("GLCanvas.removeNotify()"); + } } } @@ -289,6 +297,17 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction = new SwapBuffersOnEventDispatchThreadAction(); + class DestroyAction implements Runnable { + public void run() { + GLContext current = GLContext.getCurrent(); + if (current == context) { + context.release(); + } + context.destroy(); + } + } + private DestroyAction destroyAction = new DestroyAction(); + // Disables the AWT's erasing of this Canvas's background on Windows // in Java SE 6. This internal API is not available in previous // releases, but the system property |