From bb8454d735c511c6d80798d3b6258e1ed355579e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 19:11:26 +0200 Subject: Refine a3cb6bb14f410f67fccf5ccd4cd7ecc66f448389, fix deadlock (regression) The lock being claimed at validateGLDrawable() is 'offthread', i.e. may fight w/ AWT / Animator at reshape/display. Locking is moved 'down' to AWT runnable 'setRealizedOnEDTAction', which also double checks the drawable [again]. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 46 +++++++++++++--------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src/jogl/classes/javax/media') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 4bdae7135..a5c15dbda 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -576,29 +576,37 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( _drawable.isRealized() ) { return true; } - final RecursiveLock _lock = lock; - _lock.lock(); - try { - if (!Beans.isDesignTime() && isDisplayable() && - 0 < _drawable.getWidth() && 0 < _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; - } - } - } finally { - _lock.unlock(); + if( Beans.isDesignTime() || !isDisplayable() || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + return false; // early out! + } + // make sure drawable realization happens on AWT EDT, due to AWTTree lock + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + final boolean res = _drawable.isRealized(); + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+res+", "+_drawable.toString()); + Thread.dumpStack(); } + return res; } return false; } - private Runnable setRealizedOnEDTAction = new Runnable() { public void run() { drawable.setRealized(true); } }; + private Runnable setRealizedOnEDTAction = new Runnable() { + public void run() { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawable _drawable = drawable; + if( null == _drawable || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + return; + } + _drawable.setRealized(true); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + } + } finally { + _lock.unlock(); + } + } }; /**

Overridden to track when this component is removed from a container. Subclasses which override this method must call -- cgit v1.2.3