From dfee8c58d4915f78f57545c26a492668b2b68a87 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 Jul 2012 08:57:57 +0200 Subject: Fix SWT GLCanvas threading. Note: On OSX _only_ it's main thread is valid! --- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/nativewindow/classes/com') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index f4309617b..735d85fb1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -37,11 +37,13 @@ import org.eclipse.swt.widgets.Control; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; + import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.macosx.OSXUtil; public class SWTAccessor { @@ -254,8 +256,25 @@ public class SWTAccessor { }); } + /** + * Runs the specified action in an SWT compatible thread, which is: + * + * @see Platform#AWT_AVAILABLE + * @see Platform#getOSType() + */ public static void invoke(boolean wait, Runnable runnable) { - if(Platform.OS_TYPE == Platform.OSType.MACOS) { + if( Platform.OS_TYPE == Platform.OSType.MACOS ) { + // Use SWT main thread! Only reliable config w/ -XStartOnMainThread !? OSXUtil.RunOnMainThread(wait, runnable); } else { runnable.run(); -- cgit v1.2.3