changeset 82:0aafcf6e5217

Lazy initialization to fix cyclic dep. Thanks yidabu for the report.
author Frank Benoit <benoit@tionex.de>
date Fri, 20 Jun 2008 12:44:40 +0200
parents e28b067ce8c5
children 028aedd523ad
files dwtx/jface/dialogs/Dialog.d
diffstat 1 files changed, 50 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/dwtx/jface/dialogs/Dialog.d	Wed May 28 23:05:40 2008 +0200
+++ b/dwtx/jface/dialogs/Dialog.d	Fri Jun 20 12:44:40 2008 +0200
@@ -384,41 +384,59 @@
      * Create a default instance of the blocked handler which does not do
      * anything.
      */
-    public static IDialogBlockedHandler blockedHandler;
-    static this(){
-        blockedHandler = new class IDialogBlockedHandler {
-            /*
-            * (non-Javadoc)
-            *
-            * @see dwtx.jface.dialogs.IDialogBlockedHandler#clearBlocked()
-            */
-            public void clearBlocked() {
-                // No default behaviour
+    private static IDialogBlockedHandler blockedHandler_;
+    public static IDialogBlockedHandler blockedHandler(){
+        static_this_blockedhandler();
+        return blockedHandler_;
+    }
+    public static IDialogBlockedHandler blockedHandler( IDialogBlockedHandler b ){
+        static_this_blockedhandler();
+        return ( blockedHandler_ = b );
+    }
+    private static bool static_this_blockedhandler_completed = false;
+    private static void static_this_blockedhandler(){
+        if( static_this_blockedhandler_completed ){
+            return;
+        }
+        synchronized{
+            if( static_this_blockedhandler_completed ){
+                return;
             }
+            blockedHandler_ = new class IDialogBlockedHandler {
+                /*
+                * (non-Javadoc)
+                *
+                * @see dwtx.jface.dialogs.IDialogBlockedHandler#clearBlocked()
+                */
+                public void clearBlocked() {
+                    // No default behaviour
+                }
 
-            /*
-            * (non-Javadoc)
-            *
-            * @see dwtx.jface.dialogs.IDialogBlockedHandler#showBlocked(dwtx.core.runtime.IProgressMonitor,
-            *      dwtx.core.runtime.IStatus, java.lang.String)
-            */
-            public void showBlocked(IProgressMonitor blocking,
-                    IStatus blockingStatus, String blockedName) {
-                // No default behaviour
-            }
+                /*
+                * (non-Javadoc)
+                *
+                * @see dwtx.jface.dialogs.IDialogBlockedHandler#showBlocked(dwtx.core.runtime.IProgressMonitor,
+                *      dwtx.core.runtime.IStatus, java.lang.String)
+                */
+                public void showBlocked(IProgressMonitor blocking,
+                        IStatus blockingStatus, String blockedName) {
+                    // No default behaviour
+                }
 
-            /*
-            * (non-Javadoc)
-            *
-            * @see dwtx.jface.dialogs.IDialogBlockedHandler#showBlocked(dwt.widgets.Shell,
-            *      dwtx.core.runtime.IProgressMonitor,
-            *      dwtx.core.runtime.IStatus, java.lang.String)
-            */
-            public void showBlocked(Shell parentShell, IProgressMonitor blocking,
-                    IStatus blockingStatus, String blockedName) {
-                // No default behaviour
-            }
-        };
+                /*
+                * (non-Javadoc)
+                *
+                * @see dwtx.jface.dialogs.IDialogBlockedHandler#showBlocked(dwt.widgets.Shell,
+                *      dwtx.core.runtime.IProgressMonitor,
+                *      dwtx.core.runtime.IStatus, java.lang.String)
+                */
+                public void showBlocked(Shell parentShell, IProgressMonitor blocking,
+                        IStatus blockingStatus, String blockedName) {
+                    // No default behaviour
+                }
+            };
+            static_this_blockedhandler_completed = true;
+        }
     }
 
     /**