summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-09-28 09:44:47 +0300
committerSven Gothel <[email protected]>2010-09-28 09:44:47 +0300
commitcc39d25716fd4d934a22c4aaefb88f0c4f15a162 (patch)
tree42b6d6e07c786fc3046cbc8ab09533d665083246
parentfab1ce7a07467065842e75c9d5c60c6bc7e305e0 (diff)
NEWT Reparenting: Only lock parentWindow during native reparent attempt, otherwise it may cause deadlock (AWT EDT)
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index 02541aa73..9d5d12966 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -775,14 +775,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if( ACTION_NATIVE_REPARENTING == reparentAction ) {
- NativeWindow parentWindowLocked = null;
- if( null != parentWindow ) {
- parentWindowLocked = parentWindow;
- if(NativeWindow.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) {
- throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
- }
- }
- try {
if(0!=parentWindowHandle) {
// reset position to 0/0 within parent space
// FIXME .. cache position ?
@@ -796,26 +788,40 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
setVisibleImpl(false);
display.dispatchMessages(); // status up2date
}
- boolean ok = reparentWindowImpl();
- display.dispatchMessages(); // status up2date
- if ( !ok ) {
+
+ // Lock parentWindow only during reparenting (attempt)
+ NativeWindow parentWindowLocked = null;
+ if( null != parentWindow ) {
+ parentWindowLocked = parentWindow;
+ if(NativeWindow.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) {
+ throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
+ }
+ }
+ boolean ok = false;
+ try {
+ ok = reparentWindowImpl();
+ } finally {
+ if(null!=parentWindowLocked) {
+ parentWindowLocked.unlockSurface();
+ }
+ }
+
+ if(ok) {
+ display.dispatchMessages(); // status up2date
+ if(wasVisible) {
+ visible = true;
+ setVisibleImpl(true);
+ requestFocusImpl(true);
+ display.dispatchMessages(); // status up2date
+ }
+ } else {
// native reparent failed -> try creation
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation");
}
destroy(false);
reparentAction = ACTION_NATIVE_CREATION ;
- } if(wasVisible) {
- visible = true;
- setVisibleImpl(true);
- requestFocusImpl(true);
- display.dispatchMessages(); // status up2date
- }
- } finally {
- if(null!=parentWindowLocked) {
- parentWindowLocked.unlockSurface();
}
- }
}
if(DEBUG_IMPLEMENTATION) {