From b83b068c0f426f24a58e2bd9f52de9ebd0c7876d Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Tue, 6 Nov 2012 16:10:51 +0100
Subject: Fix GLDrawableHelper.recreateGLDrawable(..): Sync GL command stream
 before destruction of drawable

Lack of finishing the GL command stream lead to a SIGSEGV on Windows w/ Nvidia driver
where probably pending GL commands were still being processed concurrently.
---
 src/jogl/classes/jogamp/opengl/GLDrawableHelper.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/GLDrawableHelper.java')

diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index be63c9278..36dc933ab 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -173,12 +173,17 @@ public class GLDrawableHelper {
       if( ! drawable.isRealized() ) {
           return drawable;
       }
-      final boolean contextCurrent = null != context && context.isCurrent();
+      final GLContext currentContext = GLContext.getCurrent();
       final GLDrawableFactory factory = drawable.getFactory();
       final NativeSurface surface = drawable.getNativeSurface();
       final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null;
       
-      if(contextCurrent) {
+      if( null != context ) {
+          // Ensure to sync GL command stream
+          if( currentContext != context ) {
+              context.makeCurrent();
+          }
+          context.getGL().glFinish();
           context.release();
       }
       
@@ -199,8 +204,8 @@ public class GLDrawableHelper {
           context.setGLDrawable(drawable, true); // re-association
       }
       
-      if(contextCurrent) {
-          context.makeCurrent();
+      if( null != currentContext ) {
+          currentContext.makeCurrent();
       }
       return drawable;
   }
-- 
cgit v1.2.3