Mercurial > projects > dwt-addons
diff dwtx/jface/resource/JFaceResources.d @ 37:e10d9c2648be
fix static interface and static this
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Apr 2008 13:21:48 +0200 |
parents | 6886832e1ed8 |
children | c884a1ab6db3 |
line wrap: on
line diff
--- a/dwtx/jface/resource/JFaceResources.d Sun Apr 06 13:19:51 2008 +0200 +++ b/dwtx/jface/resource/JFaceResources.d Sun Apr 06 13:21:48 2008 +0200 @@ -64,8 +64,12 @@ * the associated display. */ private static Map!(Display,ResourceManager) registries; - static this(){ - registries = new HashMap!(Display,ResourceManager); + private static void init_registries(){ + if( registries is null ){ + synchronized if( registries is null ){ + registries = new HashMap!(Display,ResourceManager); + } + } } /** @@ -78,8 +82,12 @@ * The JFace resource bundle; eagerly initialized. */ private static /+final+/ ResourceBundle bundle; - static this(){ - bundle = ResourceBundle.getBundle("dwtx.jface.messages"); //$NON-NLS-1$ + private static void init_bundle(){ + if( bundle is null ){ + synchronized if( bundle is null ){ + bundle = ResourceBundle.getBundle("dwtx.jface.messages"); //$NON-NLS-1$ + } + } } /** @@ -179,6 +187,7 @@ * @return the resource bundle */ public static ResourceBundle getBundle() { + init_bundle(); return bundle; } @@ -206,6 +215,7 @@ * @return the global resource manager for the given display */ public static ResourceManager getResources(Display toQuery) { + init_registries(); ResourceManager reg = cast(ResourceManager) registries.get(toQuery); if (reg is null) { @@ -505,6 +515,7 @@ * @return the string */ public static String getString(String key) { + init_bundle(); try { return bundle.getString(key); } catch (MissingResourceException e) {