From 231f9fe67c55ece5ee013cf1183f15200b602cd8 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sat, 9 Oct 2010 21:29:05 +0200
Subject: JOGL: WindowsWGLDrawableFactory/X11GLXDrawableFactory: synchronize
 sharedContext lock/release

Unsynchronized lead to an 'context already locked by another thread' exception
at initialization time (Windows: in general; X11: ATI and pbuffer drawable).
---
 .../opengl/impl/x11/glx/X11GLXDrawableFactory.java     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

(limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11')

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 2ae53fb9d..4b84227c3 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
@@ -223,17 +223,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
      * The dummy context shall also use the same Display,
      * since switching Display in this regard is another ATI bug.
      */
-    boolean usedSharedContext=false;
     if( isVendorATI() && null == GLContext.getCurrent() ) {
-        sharedContext.makeCurrent();
-        usedSharedContext=true;
-    }
-    try {
-        pbufferDrawable = new X11PbufferGLXDrawable(this, target);
-    } finally {
-        if(usedSharedContext) {
-            sharedContext.release();
+        synchronized(sharedContext) {
+            sharedContext.makeCurrent();
+            try {
+                pbufferDrawable = new X11PbufferGLXDrawable(this, target);
+            } finally {
+                sharedContext.release();
+            }
         }
+    } else {
+        pbufferDrawable = new X11PbufferGLXDrawable(this, target);
     }
     return pbufferDrawable;
   }
-- 
cgit v1.2.3