2002/08/18 05:30:45
[org.ibex.core.git] / src / org / xwt / Surface.java
index e59dfc6..5b2f205 100644 (file)
@@ -374,19 +374,22 @@ public abstract class Surface {
     }
 
     /** Indicates that the Surface is no longer needed */
-    public final void dispose() {
+    public final void dispose(boolean quitIfAllSurfacesGone) {
         if (root == null) return;
         if (Log.on) Log.log(this, "disposing " + this);
         allSurfaces.removeElement(this);
         _dispose();
 
         // quit when all windows are closed
-        if (allSurfaces.size() == 0) {
+        if (allSurfaces.size() == 0 && quitIfAllSurfacesGone) {
+            throw new Error();
+            /*
             if (Log.on) {
                 if (refreshableSurfaceWasCreated) Log.log(this, "exiting because last remaining surface was disposed");
                 else Log.log(this, "exiting because no surface was ever created");
             }
             Platform.exit();
+            */
         }
     }
 
@@ -400,8 +403,11 @@ public abstract class Surface {
         this.scarred = scarAllSurfacesFromNowOn;
         scarAllSurfacesFromNowOn = true;
         this.root = root;
-        if (root.surface != null && root.surface.root == root) root.surface.dispose();
-        root.remove();
+        if (root.surface != null && root.surface.root == root) {
+            root.surface.dispose(false);
+        } else {
+            root.remove();
+        }
         root.setSurface(this);
 
         // make sure the root is properly sized