diff options
author | Sven Gothel <[email protected]> | 2012-11-26 18:15:59 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-11-26 18:15:59 +0100 |
commit | 8cf694c1424277e6358039a964ecd75c54cf9af9 (patch) | |
tree | 72c37d6e8efe5d64951fd5fb8ef258a679caa3ca /src/nativewindow/classes/com/jogamp | |
parent | 541bcc1eecc50656392e1fec1a27b08ab78eceff (diff) |
SWTAccessor: OS_gtk_widget_unrealize optional (SWT 4.3) ; decorate PrivilegedAction for static initSingleton block (SWTAccessor, NewtFactory, NativeWindowFactory)
Diffstat (limited to 'src/nativewindow/classes/com/jogamp')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 7be747ff5..fca132f3f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -30,6 +30,8 @@ package com.jogamp.nativewindow.swt; import com.jogamp.common.os.Platform; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; import org.eclipse.swt.graphics.GCData; import org.eclipse.swt.widgets.Control; @@ -70,7 +72,7 @@ public class SWTAccessor { static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS"; static final Class<?> OS_gtk_class; static final Method OS_gtk_widget_realize; - static final Method OS_gtk_widget_unrealize; + static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) static final Method OS_GTK_WIDGET_WINDOW; static final Method OS_gdk_x11_drawable_get_xdisplay; static final Method OS_gdk_x11_drawable_get_xid; @@ -83,6 +85,12 @@ public class SWTAccessor { static { Field f = null; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + NativeWindowFactory.initSingleton(); // last resort .. + return null; + } } ); + final String nwt = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_MACOSX != nwt ) { @@ -127,14 +135,18 @@ public class SWTAccessor { Method m1=null, m2=null, m3=null, m4=null, m5=null; Class<?> handleType = swt_uses_long_handles ? long.class : int.class ; if( NativeWindowFactory.TYPE_X11 == nwt ) { + // mandatory try { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); - m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); m4 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); } catch (Exception ex) { throw new NativeWindowException(ex); } + // optional + try { + m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); + } catch (Exception ex) { } } OS_gtk_class = c; OS_gtk_widget_realize = m1; @@ -197,7 +209,7 @@ public class SWTAccessor { public void run() { if(realize) { callStaticMethodL2V(OS_gtk_widget_realize, handle); - } else { + } else if(null != OS_gtk_widget_unrealize) { callStaticMethodL2V(OS_gtk_widget_unrealize, handle); } } |