From 7fad4be03e6d9987be420444364b6714667d32cc Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Tue, 4 May 2010 07:07:19 +0200
Subject: Remove critical path in shutdown ..

---
 .../jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java | 8 ++++++--
 .../com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java     | 6 ++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

(limited to 'src/jogl/classes/com/jogamp')

diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 70513f82d..d2eb98bdf 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -111,11 +111,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
           Exception e = new Exception("Debug");
           e.printStackTrace();
      }
+    // don't free native resources from this point on,
+    // since we might be in a critical shutdown hook sequence
      if(null!=sharedContext) {
-        sharedContext.destroy(); // implies release, if current
+        // may cause deadlock: sharedContext.destroy(); // implies release, if current
+        sharedContext=null;
      }
      if(null!=sharedDrawable) {
-        sharedDrawable.destroy();
+        // may cause deadlock: sharedDrawable.destroy();
+        sharedDrawable=null;
      }
   }
 
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index aa1767c48..823809f43 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -151,12 +151,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
                     }
                 }
 
+                // don't free native resources from this point on,
+                // since we might be in a critical shutdown hook sequence
                 if(null!=sharedDrawable) {
-                    sharedDrawable.destroy();
+                    // may cause deadlock: sharedDrawable.destroy();
                     sharedDrawable=null;
                 }
                 if(null!=sharedScreen) {
-                     X11Util.closeThreadLocalDisplay(null);
+                     // may cause deadlock: X11Util.closeThreadLocalDisplay(null);
                      sharedScreen = null;
                      sharedDevice=null;
                 }
-- 
cgit v1.2.3