From b41b720c4366d4e2cdc1ba146123b87da966d724 Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Sat, 26 Feb 2005 01:41:28 +0000
Subject: Merged with current JOGL trunk (tag JOGL_1_1_PRE_B10)

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@245 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 src/net/java/games/jogl/impl/GLContext.java | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

(limited to 'src/net/java/games/jogl/impl/GLContext.java')

diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
index 2aa8e9640..17667fbce 100644
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ b/src/net/java/games/jogl/impl/GLContext.java
@@ -44,7 +44,7 @@ import net.java.games.jogl.*;
 import net.java.games.gluegen.runtime.*;
 
 public abstract class GLContext {
-  protected static final boolean DEBUG = false;
+  protected static final boolean DEBUG = Debug.debug("GLContext");
 
   static {
     NativeLibLoader.load();
@@ -145,11 +145,7 @@ public abstract class GLContext {
                    GLCapabilitiesChooser chooser,
                    GLContext shareWith) {
     this.component = component;
-    try {
-      this.capabilities = (GLCapabilities) capabilities.clone();
-    } catch (CloneNotSupportedException e) {
-      throw new GLException(e);
-    }
+    this.capabilities = (GLCapabilities) capabilities.clone();
     this.chooser = chooser;
     setGL(createGL());
     functionAvailability = new FunctionAvailabilityCache(this);
@@ -255,6 +251,15 @@ public abstract class GLContext {
         if (isReshape) {
           deferredReshapeAction = runnable;
         }
+
+        // Clean up after ourselves on the way out.
+        // NOTE that this is an abbreviated version of the code below
+        // and should probably be refactored/cleaned up -- this bug
+        // fix was done without a lot of intense thought about the
+        // situation
+        if (curContext != null) {
+          curContext.makeCurrent(curInitAction);
+        }
         return;
       }
       if (DEBUG) {
@@ -620,6 +625,9 @@ public abstract class GLContext {
       from within the destroy() implementation. */
   protected synchronized void setRealized(boolean realized) {
     this.realized = realized;
+    if (DEBUG) {
+      System.err.println("GLContext.setRealized(" + realized + ") for context " + this);
+    }
   }
 
   /** Indicates whether the component associated with this context has
-- 
cgit v1.2.3