comparison dwtx/draw2d/SimpleEtchedBorder.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
comparison
equal deleted inserted replaced
102:0de61c6f08ca 103:2d6540440fe6
28 public final class SimpleEtchedBorder 28 public final class SimpleEtchedBorder
29 : SchemeBorder 29 : SchemeBorder
30 { 30 {
31 31
32 /** The singleton instance of this class */ 32 /** The singleton instance of this class */
33 public static const Border singleton; 33 private static Border singleton_;
34 34
35 /** The insets */ 35 /** The insets */
36 protected static const Insets INSETS; 36 private static Insets INSETS_;
37 37
38 static this(){ 38 public static Border singleton(){
39 singleton = new SimpleEtchedBorder(); 39 if( !initStaticCtor_done ) initStaticCtor();
40 INSETS = new Insets(2); 40 assert(singleton_);
41 return singleton_;
41 } 42 }
43 protected static Insets INSETS(){
44 if( !initStaticCtor_done ) initStaticCtor();
45 assert(INSETS_);
46 return INSETS_;
47 }
48
49 private static bool initStaticCtor_done = false;
50 private static void initStaticCtor(){
51 synchronized( SimpleEtchedBorder.classinfo ){
52 if( !initStaticCtor_done ){
53 singleton_ = new SimpleEtchedBorder();
54 INSETS_ = new Insets(2);
55 initStaticCtor_done = true;
56 }
57 }
58 }
59
60
61
62
42 /** 63 /**
43 * Constructs a default border having a two pixel wide border. 64 * Constructs a default border having a two pixel wide border.
44 * 65 *
45 * @since 2.0 66 * @since 2.0
46 */ 67 */