summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-27 14:12:41 +0100
committerSven Gothel <[email protected]>2014-01-27 14:12:41 +0100
commitb7fafd30ffc5eac73880b264043582d74175a394 (patch)
tree8e746fa4904c3b35e90971ab8f940e47153f582f /src/nativewindow/classes
parentb92a813063212130d6205a25b1f84662e8c4c0f9 (diff)
Bug 952 - JAWTWindow.JAWTComponentListener's ctor() and detach() may deadlock due to AWTTreeLock acquisition while add/remove AWT listener
The AWTTreeLock is acquired by Component.removeHierarchyListener and as for _every_ AWT component, modifications shall happen on the AWT-EDT. IMHO the user shall offload AWT modifications to the AWT-EDT similar to what JOGL's GLCanvas and NEWTCanvasAWT does. However, since JAWTWindow also represents a NativeWindow instance we shall offload AWTTreeLock methods ourselves!
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index a4dfe1c04..a57dafc92 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -163,19 +163,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
private JAWTComponentListener() {
isShowing = component.isShowing();
- if(DEBUG) {
- System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+toString());
- }
- component.addComponentListener(this);
- component.addHierarchyListener(this);
+ AWTEDTExecutor.singleton.invoke(false, new Runnable() { // Bug 952: Avoid deadlock via AWTTreeLock acquisition ..
+ @Override
+ public void run() {
+ if(DEBUG) {
+ System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+JAWTComponentListener.this.toString());
+ }
+ component.addComponentListener(JAWTComponentListener.this);
+ component.addHierarchyListener(JAWTComponentListener.this);
+ } } );
}
private final void detach() {
- if(DEBUG) {
- System.err.println(jawtStr()+".detach @ Thread "+getThreadName()+": "+toString());
- }
- component.removeComponentListener(this);
- component.removeHierarchyListener(this);
+ AWTEDTExecutor.singleton.invoke(false, new Runnable() { // Bug 952: Avoid deadlock via AWTTreeLock acquisition ..
+ @Override
+ public void run() {
+ if(DEBUG) {
+ System.err.println(jawtStr()+".detach @ Thread "+getThreadName()+": "+JAWTComponentListener.this.toString());
+ }
+ component.removeComponentListener(JAWTComponentListener.this);
+ component.removeHierarchyListener(JAWTComponentListener.this);
+ } } );
}
@Override
@@ -601,6 +609,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
public void destroy() {
surfaceLock.lock();
try {
+ if(DEBUG) {
+ System.err.println(jawtStr()+".destroy @ Thread "+getThreadName());
+ }
jawtComponentListener.detach();
invalidate();
} finally {