From eb7a559ca0e08e479348cbe39980481a20482775 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 06:50:09 +0000 Subject: [PATCH] 2002/08/18 05:27:01 darcs-hash:20040130065009-2ba56-71d4052c2a58fa53b722ffa0f53bda3f716dcaf1.gz --- CHANGES | 7 +++++++ src/org/xwt/Box.java | 2 +- src/org/xwt/SpecialBoxProperty.java | 4 ++-- src/org/xwt/Surface.java | 14 ++++++++++---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 9c48e7f..f5b7e60 100644 --- a/CHANGES +++ b/CHANGES @@ -369,5 +369,12 @@ 16-Aug megacz AWT.java, Java12.java, Java14.java: fixed jdk1.4 bug with keypresses and frameless windows. +16-Aug megacz XWT.java, SpecialBoxProperty.java: box.apply() + +17-Aug megacz Box.java, SpecialBoxProperty.java, Surface.java: code to + prevent engine from quitting when changing the last + remaining surface from a frame to a window or vice + versa. + diff --git a/src/org/xwt/Box.java b/src/org/xwt/Box.java index 86eb459..1a1f672 100644 --- a/src/org/xwt/Box.java +++ b/src/org/xwt/Box.java @@ -1314,7 +1314,7 @@ public final class Box extends JSObject { /** remove this node from its parent; INVARIANT: whenever the parent of a node is changed, remove() gets called. */ public void remove() { if (parent == null) { - if (surface != null) surface.dispose(); + if (surface != null) surface.dispose(true); return; } Box oldparent = getParent(); diff --git a/src/org/xwt/SpecialBoxProperty.java b/src/org/xwt/SpecialBoxProperty.java index 6302f49..f9880bf 100644 --- a/src/org/xwt/SpecialBoxProperty.java +++ b/src/org/xwt/SpecialBoxProperty.java @@ -573,7 +573,7 @@ class SpecialBoxProperty { specialBoxProperties.put("Close", new SpecialBoxProperty() { public void put(Box b, Object value) { - if (b.getParent() == null && b.surface != null) b.surface.dispose(); + if (b.getParent() == null && b.surface != null) b.surface.dispose(true); } }); @@ -713,7 +713,7 @@ class SpecialBoxProperty { if (Log.on) Log.log(this, "template " + templatename + " not found at " + Context.enter().interpreterSourceFile + ":" + Context.enter().interpreterLine); } else { - if (!ThreadMessage.suspendThread()) try { + if (ThreadMessage.suspendThread()) try { Function callback = args.length < 2 ? null : (Function)args[1]; t.apply(b, null, null, callback, 0, t.numUnits()); } finally { diff --git a/src/org/xwt/Surface.java b/src/org/xwt/Surface.java index e59dfc6..5b2f205 100644 --- a/src/org/xwt/Surface.java +++ b/src/org/xwt/Surface.java @@ -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 -- 1.7.10.4