aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-05 19:11:26 +0200
committerSven Gothel <[email protected]>2012-10-05 19:11:26 +0200
commitbb8454d735c511c6d80798d3b6258e1ed355579e (patch)
treeab7ed29ba38c4005434257e5db89390023fad736 /src/jogl
parent67c2ab9bbc3522d85977151849c416f5aa320395 (diff)
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].
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java46
1 files changed, 27 insertions, 19 deletions
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();
+ }
+ } };
/** <p>Overridden to track when this component is removed from a
container. Subclasses which override this method must call