diff dwtx/jface/resource/FontRegistry.d @ 90:7ffeace6c47f

Update 3.4M7 to 3.4
author Frank Benoit <benoit@tionex.de>
date Sun, 06 Jul 2008 23:30:07 +0200
parents d0467f3a67b3
children 04b47443bb01
line wrap: on
line diff
--- a/dwtx/jface/resource/FontRegistry.d	Sun Jun 22 22:57:31 2008 +0200
+++ b/dwtx/jface/resource/FontRegistry.d	Sun Jul 06 23:30:07 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -70,6 +70,7 @@
  * </p>
  *
  * Since 3.0 this class extends ResourceRegistry.
+ * @noextend This class is not intended to be subclassed by clients.
  */
 public class FontRegistry : ResourceRegistry {
 
@@ -217,6 +218,10 @@
      */
     protected Runnable displayRunnable;
 
+    private bool displayDisposeHooked;
+
+    private final bool cleanOnDisplayDisposal;
+
     /**
      * Creates an empty font registry.
      * <p>
@@ -292,6 +297,7 @@
         //readResourceBundle(location, loader);
         readResourceBundle(location);
 
+        cleanOnDisplayDisposal = true;
         hookDisplayDispose(display);
     }
 
@@ -410,6 +416,7 @@
     public this(Display display, bool cleanOnDisplayDisposal) {
         initInstance();
         Assert.isNotNull(display);
+        this.cleanOnDisplayDisposal = cleanOnDisplayDisposal;
         if (cleanOnDisplayDisposal) {
             hookDisplayDispose(display);
         }
@@ -534,6 +541,9 @@
         if (display is null) {
             return null;
         }
+        if (cleanOnDisplayDisposal && !displayDisposeHooked) {
+            hookDisplayDispose(display);
+        }
 
         FontData[] validData = filterData(fonts, display);
         if (validData.length is 0) {
@@ -732,12 +742,15 @@
 
         stringToFontRecord.clear();
         staleFonts.clear();
+        
+        displayDisposeHooked = false;
     }
 
     /**
      * Hook a dispose listener on the DWT display.
      */
     private void hookDisplayDispose(Display display) {
+        displayDisposeHooked = true;
         display.disposeExec(displayRunnable);
     }