diff dwt/widgets/Label.d @ 80:1801ddeb8f32

removed static ctors
author Frank Benoit <benoit@tionex.de>
date Wed, 06 Feb 2008 12:09:44 +0100
parents 0f25be5cbe6f
children 6f75fdfa1bcd
line wrap: on
line diff
--- a/dwt/widgets/Label.d	Wed Feb 06 11:08:01 2008 +0100
+++ b/dwt/widgets/Label.d	Wed Feb 06 12:09:44 2008 +0100
@@ -60,14 +60,26 @@
     Image image;
     static const int MARGIN = 4;
     static const bool IMAGE_AND_TEXT = false;
-    static const WNDPROC LabelProc;
+    private static /+const+/ WNDPROC LabelProc;
     static const TCHAR[] LabelClass = "STATIC\0";
-    static this() {
-        WNDCLASS lpWndClass;
-        OS.GetClassInfo (null, LabelClass.ptr, &lpWndClass);
-        LabelProc = lpWndClass.lpfnWndProc;
+
+    private static bool static_this_completed = false;
+    private static void static_this() {
+        if( static_this_completed ){
+            return;
+        }
+        synchronized {
+            if( static_this_completed ){
+                return;
+            }
+            WNDCLASS lpWndClass;
+            OS.GetClassInfo (null, LabelClass.ptr, &lpWndClass);
+            LabelProc = lpWndClass.lpfnWndProc;
+            static_this_completed = true;
+        }
     }
 
+
 /**
  * Constructs a new instance of this class given its parent
  * and a style value describing its behavior and appearance.
@@ -106,6 +118,7 @@
  * @see Widget#getStyle
  */
 public this (Composite parent, int style) {
+    static_this();
     super (parent, checkStyle (style));
 }