Fixes issue 792 by adding guards to detatch, also throws IllegalStateException if we ever try to attach when not attached, or detach when not detached.
Review by: jgw
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@946 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/RootPanel.java b/user/src/com/google/gwt/user/client/ui/RootPanel.java
index d393851..c3d9d1c 100644
--- a/user/src/com/google/gwt/user/client/ui/RootPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/RootPanel.java
@@ -85,8 +85,8 @@
* @return the document's body element
*/
public static native Element getBodyElement() /*-{
- return $doc.body;
- }-*/;
+ return $doc.body;
+ }-*/;
private static void hookWindowClosing() {
// Catch the window closing event.
@@ -97,7 +97,9 @@
// avoid potential memory leaks.
for (Iterator it = rootPanels.values().iterator(); it.hasNext();) {
RootPanel gwt = (RootPanel) it.next();
- gwt.onDetach();
+ if (gwt.isAttached()) {
+ gwt.onDetach();
+ }
}
}