From 4c27377366a338ca9049006dd45672dad0f770ce Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 15 Dec 2010 03:39:35 +0100 Subject: JAWTUtil: Fix case when init is run on AWT EDT (which is odd, ie not using GLProfile.initSingleton(..) --- .../jogamp/nativewindow/impl/jawt/JAWTUtil.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/nativewindow/classes/com') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java index 0f1b85cd9..68d6dc2a8 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java @@ -115,18 +115,23 @@ public class JAWTUtil { jawtToolkitLock = new JAWTToolkitLock(); - // trigger native AWT toolkit initialization - final ArrayList desktophintsBucket = new ArrayList(); + // trigger native AWT toolkit / properties initialization + Map desktophints = null; try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - Toolkit tk = Toolkit.getDefaultToolkit(); - Map desktophints = (Map)(tk.getDesktopProperty("awt.font.desktophints")); - if(null!=desktophints) { - desktophintsBucket.add(desktophints); + if(EventQueue.isDispatchThread()) { + desktophints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); + } else { + final ArrayList desktophintsBucket = new ArrayList(); + EventQueue.invokeAndWait(new Runnable() { + public void run() { + Map _desktophints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); + if(null!=_desktophints) { + desktophintsBucket.add(_desktophints); + } } - } - }); + }); + desktophints = ( desktophintsBucket.size() > 0 ) ? (Map)desktophintsBucket.get(0) : null ; + } } catch (InterruptedException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { @@ -137,7 +142,7 @@ public class JAWTUtil { System.err.println("JAWTUtil: Has sun.awt.SunToolkit.awtLock/awtUnlock " + hasSunToolkitAWTLock); System.err.println("JAWTUtil: Has Java2D " + j2dExist); System.err.println("JAWTUtil: Is headless " + headlessMode); - int hints = ( desktophintsBucket.size() > 0 ) ? ((Map)desktophintsBucket.get(0)).size() : 0 ; + int hints = ( null != desktophints ) ? desktophints.size() : 0 ; System.err.println("JAWTUtil: AWT Desktop hints " + hints); } } -- cgit v1.2.3