aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-06-29 04:15:21 +0200
committerSven Gothel <[email protected]>2012-06-29 04:15:21 +0200
commit0d7c3ed619044723cf561df424eac9992e5281c7 (patch)
tree3ffa52aa71536a3321b9bf7e59de7ee28ede5917 /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parentd10c7916a2444b6cb1cf45be3ccb3d6e91a2f1b4 (diff)
GLContextImpl/GLDrawableImpl: More fail-safe, cleanup, mark some methods final
GLContextImpl: Cleanup - release(): simplify the conditions - destroy(): allow locked twice before (destroy case) GLDrawableImpl: - fail safe: swapBuffers - final methods: getFactoryImpl, toHexString, getGLProfile, getRequestedGLCapabilities, getFactory, isRealized, lockSurface, unlockSurface
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index ea024e691..4ef8b9750 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -233,12 +233,10 @@ public abstract class GLContextImpl extends GLContext {
if ( !lock.isOwner(Thread.currentThread()) ) {
throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this);
}
- final boolean actualRelease = force || lock.getHoldCount() == 1 ;
+ final boolean actualRelease = ( force || lock.getHoldCount() == 1 ) && 0 != contextHandle;
try {
if( actualRelease ) {
- if (contextHandle != 0) { // allow dbl-release
- releaseImpl();
- }
+ releaseImpl();
}
} finally {
// exception prone ..
@@ -269,11 +267,16 @@ public abstract class GLContextImpl extends GLContext {
try {
// Must hold the lock around the destroy operation to make sure we
// don't destroy the context while another thread renders to it.
- // FIXME: This is actually impossible now, since we acquired the surface lock already,
- // which is a prerequisite to acquire the context lock.
- lock.lock(); // holdCount++ -> 1 or 2
+ lock.lock(); // holdCount++ -> 1 - 3 (1: not locked, 2-3: destroy while rendering)
if ( lock.getHoldCount() > 2 ) {
- throw new GLException(getThreadName() + ": Lock was hold more than once - makeCurrent/release imbalance: "+lock);
+ final String msg = getThreadName() + ": GLContextImpl.destroy: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle);
+ if (DEBUG || TRACE_SWITCH) {
+ System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+lock);
+ Thread.dumpStack();
+ }
+ if ( lock.getHoldCount() > 3 ) {
+ throw new GLException(msg+" - Lock was hold more than twice - makeCurrent/release imbalance: "+lock);
+ }
}
try {
// release current context