Mercurial > projects > dwt-addons
diff dwtx/draw2d/graph/Path.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/graph/Path.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/graph/Path.d Sun Aug 03 17:01:51 2008 +0200 @@ -52,14 +52,24 @@ } -private static const Point CURRENT; +private static bool initStaticCtor_done = false; +private static Point CURRENT; private static const double EPSILON = 1.04; -private static const Point NEXT; +private static Point NEXT; private static const double OVAL_CONSTANT = 1.13; -static this(){ - CURRENT = new Point(); - NEXT = new Point(); +private static void initStaticCtor(){ + if( !initStaticCtor_done ){ + synchronized( Path.classinfo ){ + if( !initStaticCtor_done ){ + CURRENT = new Point(); + NEXT = new Point(); + initStaticCtor_done = true; + } + } + } + assert( CURRENT ); + assert( NEXT ); } /** @@ -101,6 +111,7 @@ * @since 3.0 */ public this() { + initStaticCtor(); segments = new ArrayList(); grownSegments = new ArrayList(); points = new PointList();