aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-04-06 13:24:02 +0200
committerSven Gothel <[email protected]>2020-04-06 13:24:02 +0200
commit7c40f03ff7030e146c73267f886c5e30bcdc4771 (patch)
tree1116a8702a1aeb80d8bc300dcd8bd33e2f6f47f3 /src/jogl/classes/jogamp/opengl
parent0205dfbb42e3b0ec05294856ee3587d57ab328e3 (diff)
Bug 1398: MacOSXCGLContext: Ensure AWT is available before using it when query java.awt.EventQueue.isDispatchThread()bug1398
If AWT is not available, isAWTEventDispatchThread() returns false, otherwise returns java.awt.EventQueue.isDispatchThread().
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java17
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();
}