From 0790108ca9c2a6a6d494e5017589fe083c518e23 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Sep 2012 20:36:27 +0200 Subject: JAWTUtil ToolkitLock: Add lock counter to make lock validation recursive (Fix regression of commit 92398025abdabb2fdef0d78edd41e730991a6f94) --- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 2dadfb16b..67c64a95c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -81,6 +81,7 @@ public class JAWTUtil { private static final boolean hasSunToolkitAWTLock; private static volatile Thread exclusiveOwnerThread; + private static int lockCounter; private static final ToolkitLock jawtToolkitLock; @@ -232,6 +233,7 @@ public class JAWTUtil { hasSunToolkitAWTLock = _hasSunToolkitAWTLock; // hasSunToolkitAWTLock = false; exclusiveOwnerThread = null; + lockCounter = 0; jawtToolkitLock = new ToolkitLock() { public final void lock() { @@ -334,7 +336,10 @@ public class JAWTUtil { } else { jawtLockObject.Lock(); } - exclusiveOwnerThread = Thread.currentThread(); + if(0 == lockCounter) { + exclusiveOwnerThread = Thread.currentThread(); + } + lockCounter++; } /** @@ -345,7 +350,10 @@ public class JAWTUtil { */ private static final void awtUnlock() { awtValidateLocked(); - exclusiveOwnerThread = null; + lockCounter--; + if(0 == lockCounter) { + exclusiveOwnerThread = null; + } if(hasSunToolkitAWTLock) { try { sunToolkitAWTUnlockMethod.invoke(null, (Object[])null); -- cgit v1.2.3