diff options
author | Sven Gothel <[email protected]> | 2020-04-06 13:24:02 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-04-06 13:28:08 +0200 |
commit | 5c729959363167f3b9286c4b82d8d0347ef6fca8 (patch) | |
tree | 96afb49e54dcbb3d788f10a508164effb2979767 | |
parent | 685695952ee273a6ca9939f0b9566427bc542349 (diff) |
Bug 1398: MacOSXCGLContext: Ensure AWT is available before using it when query java.awt.EventQueue.isDispatchThread()
If AWT is not available, isAWTEventDispatchThread() returns false,
otherwise returns java.awt.EventQueue.isDispatchThread().
-rw-r--r-- | src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index f06319fcc..38f5bb727 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -40,7 +40,6 @@ package jogamp.opengl.macosx.cgl; -import java.awt.EventQueue; import java.nio.IntBuffer; import java.util.Map; @@ -617,6 +616,14 @@ public class MacOSXCGLContext extends GLContextImpl } } + private static final boolean isAWTEventDispatchThread() { + if( NativeWindowFactory.isAWTAvailable() ) { + return java.awt.EventQueue.isDispatchThread(); + } else { + return false; + } + } + // NSOpenGLContext-based implementation class NSOpenGLImpl implements GLBackendImpl { private OffscreenLayerSurface backingLayerHost; @@ -703,7 +710,7 @@ public class MacOSXCGLContext extends GLContextImpl screenVSyncTimeout = 1000000 / sRefreshRate; } if(DEBUG) { - System.err.println("NS create OSX>=lion "+isLionOrLater+", OSX>=mavericks "+isMavericksOrLater+" - isAWTEDT "+EventQueue.isDispatchThread()+", "+Thread.currentThread()); + System.err.println("NS create OSX>=lion "+isLionOrLater+", OSX>=mavericks "+isMavericksOrLater+" - isAWTEDT "+isAWTEventDispatchThread()+", "+Thread.currentThread()); System.err.println("NS create drawable type: "+drawable.getClass().getName()); System.err.println("NS create surface type: "+surface.getClass().getName()); System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); @@ -1038,7 +1045,7 @@ public class MacOSXCGLContext extends GLContextImpl if(!insideContextMadeCurrent) { System.err.println(); } - System.err.println("MaxOSXCGLContext.makeCurrent Bug1398: recursive "+insideContextMadeCurrent+", nsViewChanged "+nsViewChanged+", isAWTEDT "+EventQueue.isDispatchThread()+", "+Thread.currentThread()); + System.err.println("MaxOSXCGLContext.makeCurrent Bug1398: recursive "+insideContextMadeCurrent+", nsViewChanged "+nsViewChanged+", isAWTEDT "+isAWTEventDispatchThread()+", "+Thread.currentThread()); System.err.println(" NSViewDescriptor: last "+lastNSViewDescr); System.err.println(" NSViewDescriptor: curr "+nsViewDescr); } @@ -1085,7 +1092,7 @@ public class MacOSXCGLContext extends GLContextImpl @Override public void contextMadeCurrent(final boolean current) { - if( current && !insideContextMadeCurrent && !cglContextLocked && !EventQueue.isDispatchThread() ) { + if( current && !insideContextMadeCurrent && !cglContextLocked && !isAWTEventDispatchThread() ) { // Bug 1398: Cure missing CGLContextLock by context release/makeCurrent cycle outside context acquisition code, // only for user makeCurrent calls, not createContext*() only. // See SetNSViewCmd API-doc. @@ -1149,7 +1156,7 @@ public class MacOSXCGLContext extends GLContextImpl } } if( DEBUG1398 ) { - System.err.println("MaxOSXCGLContext.release Bug1398: recursive "+insideContextMadeCurrent+", cglContextLocked "+cglContextLocked+", isAWTEDT "+EventQueue.isDispatchThread()+", "+Thread.currentThread()); + System.err.println("MaxOSXCGLContext.release Bug1398: recursive "+insideContextMadeCurrent+", cglContextLocked "+cglContextLocked+", isAWTEDT "+isAWTEventDispatchThread()+", "+Thread.currentThread()); if(!insideContextMadeCurrent) { System.err.println(); } |