summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/GLContext.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2004-11-18 23:06:11 +0000
committerKenneth Russel <[email protected]>2004-11-18 23:06:11 +0000
commit0f4826aff7b84698df7c465782c81102a6160a30 (patch)
tree2eab8ceb2899fe98e74d7041daa85717ee855235 /src/net/java/games/jogl/impl/GLContext.java
parent70c096c01fb666844adbd488e3309830ddd0ba1a (diff)
Fixed Issue 22: GLException hides user exception
The central try/finally cause in GLException.invokeGL() called GLContext.free() after catching and rethrowing the end user's exception from the GLEventListenerdisplay() routine, which caused the end user's exception to be overwritten with the internal GLException. Fixed this by initializing the cause of the internal exception, and also continuing to propagate out the end user's exception. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@171 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/GLContext.java')
-rw-r--r--src/net/java/games/jogl/impl/GLContext.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
index 5a56bf9ee..443d009dc 100644
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ b/src/net/java/games/jogl/impl/GLContext.java
@@ -280,7 +280,8 @@ public abstract class GLContext {
ctxStack.push(this, initAction);
}
- boolean caughtException = false;
+ RuntimeException userException = null;
+ GLException internalException = null;
try {
if (deferredReshapeAction != null) {
@@ -292,10 +293,10 @@ public abstract class GLContext {
swapBuffers();
}
} catch (RuntimeException e) {
- caughtException = true;
- throw(e);
+ userException = e;
+ throw(userException);
} finally {
- if (caughtException) {
+ if (userException != null) {
// Disallow setRenderingThread if display action is throwing exceptions
renderingThread = null;
}
@@ -316,13 +317,21 @@ public abstract class GLContext {
System.err.println("Freeing context " + this);
}
- free();
+ try {
+ free();
+ } catch (GLException e) {
+ internalException = e;
+ }
if (curContext != null) {
if (DEBUG) {
System.err.println("Making context " + curContext + " current again");
}
- curContext.makeCurrent(curInitAction);
+ try {
+ curContext.makeCurrent(curInitAction);
+ } catch (GLException e) {
+ internalException = e;
+ }
}
}
@@ -334,11 +343,28 @@ public abstract class GLContext {
assert(savedPerThreadContext == curContext);
ctxStack.pop();
if (savedPerThreadContext.getRenderingThread() == null) {
- savedPerThreadContext.free();
+ try {
+ savedPerThreadContext.free();
+ } catch (GLException e) {
+ internalException = e;
+ }
} else {
setPerThreadSavedCurrentContext(savedPerThreadContext, savedPerThreadInitAction);
}
}
+
+ // Make sure the end user's exception shows up in any stack
+ // traces; the rethrow of the userException above should take
+ // precedence if the internalException will otherwise squelch it
+ if (internalException != null) {
+ if (userException != null &&
+ internalException.getCause() == null) {
+ internalException.initCause(userException);
+ throw(internalException);
+ } else if (userException == null) {
+ throw(internalException);
+ }
+ }
}
}