diff dwtx/draw2d/CheckBox.d @ 103:2d6540440fe6

Replace static ctors with lazy init.
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 17:01:51 +0200
parents 95307ad235d9
children
line wrap: on
line diff
--- a/dwtx/draw2d/CheckBox.d	Sun Aug 03 03:07:30 2008 +0200
+++ b/dwtx/draw2d/CheckBox.d	Sun Aug 03 17:01:51 2008 +0200
@@ -33,13 +33,31 @@
 
 private Label label = null;
 
-static const Image
-    UNCHECKED,
-    CHECKED;
+private static Image
+    UNCHECKED_,
+    CHECKED_;
 
-static this(){
-    UNCHECKED = createImage( getImportData!("dwtx.draw2d.checkboxenabledoff.gif")); //$NON-NLS-1$
-    CHECKED = createImage( getImportData!("dwtx.draw2d.checkboxenabledon.gif")); //$NON-NLS-1$
+package static Image UNCHECKED(){
+    if( UNCHECKED_ is null ){
+        synchronized( CheckBox.classinfo ){
+            if( UNCHECKED_ is null ){
+                UNCHECKED_ = createImage( getImportData!("dwtx.draw2d.checkboxenabledoff.gif"));
+            }
+        }
+    }
+    assert( UNCHECKED_ );
+    return UNCHECKED_;
+}
+package static Image CHECKED(){
+    if( CHECKED_ is null ){
+        synchronized( CheckBox.classinfo ){
+            if( CHECKED_ is null ){
+                CHECKED_ = createImage( getImportData!("dwtx.draw2d.checkboxenabledon.gif"));
+            }
+        }
+    }
+    assert( CHECKED_ );
+    return CHECKED_;
 }
 
 private static Image createImage( ImportData importdata ) {