diff dwtx/draw2d/IFigure.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 2be5f40557e6
line wrap: on
line diff
--- a/dwtx/draw2d/IFigure.d	Sun Aug 03 03:07:30 2008 +0200
+++ b/dwtx/draw2d/IFigure.d	Sun Aug 03 17:01:51 2008 +0200
@@ -58,25 +58,43 @@
     }
 }
 
-static this(){
-    IFigure_MAX_DIMENSION = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
-    IFigure_MIN_DIMENSION = new Dimension(5, 5);
-    IFigure_NO_INSETS = new NoInsets();
+private static bool initStaticCtor_done = false;
+private static void initStaticCtor (){
+    synchronized( IFigure.classinfo ){
+        if( !initStaticCtor_done ){
+            IFigure_MAX_DIMENSION_ = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+            IFigure_MIN_DIMENSION_ = new Dimension(5, 5);
+            IFigure_NO_INSETS_ = new NoInsets();
+            initStaticCtor_done = true;
+        }
+    }
 }
 /**
  * The maximum allowable dimension. ({@link Integer#MAX_VALUE},{@link Integer#MAX_VALUE})
  */
-static const Dimension IFigure_MAX_DIMENSION;
+private static Dimension IFigure_MAX_DIMENSION_;
+static Dimension IFigure_MAX_DIMENSION(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return IFigure_MAX_DIMENSION_;
+}
 
 /**
  * The minimum allowable dimension. (5,5)
  */
-static const Dimension IFigure_MIN_DIMENSION;
+private static Dimension IFigure_MIN_DIMENSION_;
+static Dimension IFigure_MIN_DIMENSION(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return IFigure_MIN_DIMENSION_;
+}
 
 /**
  * Empty Insets.
  */
-static const Insets IFigure_NO_INSETS;
+private static Insets IFigure_NO_INSETS_;
+static Insets IFigure_NO_INSETS(){
+    if( !initStaticCtor_done ) initStaticCtor();
+    return IFigure_NO_INSETS_;
+}
 
 
 /**