summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-11-08 18:07:19 +0100
committerSven Gothel <[email protected]>2012-11-08 18:07:19 +0100
commitd0f91a8ed17fbb1a7b56511c4e53a29e576f01af (patch)
tree3e3f906f794ba1abe340190a4dfac12dadf5c921 /src/jogl/classes/javax
parent9ce042df68b70a0e62b21b93d2a1a64722e1e49e (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/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java90
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java29
2 files changed, 65 insertions, 54 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 1d8666e6a..a40cdcf88 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -888,33 +888,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
//
private boolean disposeRegenerate;
- private final Runnable postDisposeOnEDTAction = new Runnable() {
- @Override
- public void run() {
- context=null;
- if(null!=drawable) {
- drawable.setRealized(false);
- drawable=null;
- if(null!=jawtWindow) {
- jawtWindow.destroy();
- jawtWindow=null;
- }
- }
-
- if(disposeRegenerate) {
- // Similar process as in addNotify()!
-
- // Recreate GLDrawable/GLContext to reflect it's new graphics configuration
- createDrawableAndContext();
-
- if(DEBUG) {
- System.err.println(getThreadName()+": GLCanvas.dispose(true): new drawable: "+drawable);
- }
- validateGLDrawable(); // immediate attempt to recreate the drawable
- }
- }
- };
-
private final Runnable disposeOnEDTAction = new Runnable() {
@Override
public void run() {
@@ -929,31 +902,64 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
Thread.dumpStack();
}
- if(null!=drawable && null!=context) {
- boolean animatorPaused = false;
- if(null!=animator) {
- // can't remove us from animator for recreational addNotify()
- animatorPaused = animator.pause();
- }
-
- if(context.isCreated()) {
- helper.disposeGL(GLCanvas.this, drawable, context, postDisposeOnEDTAction);
+ 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);
+ if(DEBUG) {
+ System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 1: "+drawable);
}
-
- if(animatorPaused) {
- animator.resume();
+ drawable=null;
+ }
+ if( null != jawtWindow ) {
+ jawtWindow.destroy();
+ if(DEBUG) {
+ System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 2: "+jawtWindow);
}
+ jawtWindow=null;
}
-
- if(!disposeRegenerate) {
+
+ if(disposeRegenerate) {
+ // Similar process as in addNotify()!
+
+ // Recreate GLDrawable/GLContext to reflect it's new graphics configuration
+ createDrawableAndContext();
+
+ if(DEBUG) {
+ System.err.println(getThreadName()+": GLCanvas.dispose(true): new drawable: "+drawable);
+ }
+ validateGLDrawable(); // immediate attempt to recreate the drawable
+ } else {
if(null != awtConfig) {
AWTEDTExecutor.singleton.invoke(getTreeLock(), true, disposeAbstractGraphicsDeviceActionOnEDT);
}
awtConfig=null;
}
+ if(animatorPaused) {
+ animator.resume();
+ }
+
if(DEBUG) {
- System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, "+animator);
+ System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, animator "+animator);
}
} finally {
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 58b1baa65..dcfc1f0dd 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -757,21 +757,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+"]";
}
- private final Runnable postDisposeAction = new Runnable() {
- @Override
- public void run() {
- if (backend != null && !backend.isUsingOwnThreadManagment()) {
- backend.destroy();
- backend = null;
- isInitialized = false;
- }
- }
- };
-
private final Runnable disposeAction = new Runnable() {
@Override
public void run() {
- helper.disposeGL(GLJPanel.this, backend.getDrawable(), backend.getContext(), postDisposeAction);
+ if ( null != backend ) {
+ final GLContext _context = backend.getContext();
+ if( null != _context && _context.isCreated() ) {
+ // Catch dispose GLExceptions by GLEventListener, just 'print' them
+ // so we can continue with the destruction.
+ try {
+ helper.disposeGL(GLJPanel.this, _context);
+ } catch (GLException gle) {
+ gle.printStackTrace();
+ }
+ }
+ if ( !backend.isUsingOwnThreadManagment() ) {
+ backend.destroy();
+ backend = null;
+ isInitialized = false;
+ }
+ }
}
};