diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 335322b..0f05a91 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -440,7 +440,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void display() { + if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } Threading.invoke(true, displayOnEDTAction, getTreeLock()); + awtWindowClosingProtocol.addClosingListenerOneShot(); } @@ -570,22 +577,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( _drawable.isRealized() ) { return true; } - if (!Beans.isDesignTime() && - 0 < _drawable.getWidth() * _drawable.getHeight() ) { - // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); - if( _drawable.isRealized() ) { - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); - Thread.dumpStack(); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if (!Beans.isDesignTime() && + 0 < _drawable.getWidth() * _drawable.getHeight() ) { + // make sure drawable realization happens on AWT EDT, due to AWTTree lock + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); + } + return true; } - return true; } + } finally { + _lock.unlock(); } } return false; } + private Runnable setRealizedOnEDTAction = new Runnable() { @Override public void run() { @@ -984,11 +998,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if( validateGLDrawable() ) { - helper.invokeGL(drawable, context, displayAction, initAction); - } else if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); - } + helper.invokeGL(drawable, context, displayAction, initAction); } finally { _lock.unlock(); }