Revision: 7924
Author: jlaba...@google.com
Date: Thu Apr 15 11:30:12 2010
Log: Fixes a bug in PopupPanel where it can enter an invalid state if it is shown while attached to a panel.
http://gwt-code-reviews.appspot.com/298804/show

Review by: sp...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=7924

Modified:
 /trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java
 /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java

=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java Thu Mar 18 11:37:10 2010 +++ /trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java Thu Apr 15 11:30:12 2010
@@ -1001,6 +1001,11 @@
   public void show() {
     if (showing) {
       return;
+    } else if (isAttached()) {
+ // The popup is attached directly to another panel, so we need to remove + // it from its parent before showing it. This is a weird use case, but
+      // since PopupPanel is a Widget, its legal.
+      this.removeFromParent();
     }
     resizeAnimation.setState(true, false);
   }
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java Fri Apr 2 04:07:16 2010 +++ /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java Thu Apr 15 11:30:12 2010
@@ -428,7 +428,23 @@
   }

   /**
- * Test the showing a popup while it is hiding will not result in an illegal
+   * Test that showing a popup while it is attached does not put it in an
+   * invalid state.
+   */
+  public void testShowWhileAttached() {
+    PopupPanel popup = createPopupPanel();
+    RootPanel.get().add(popup);
+    popup.show();
+    assertTrue(popup.isAttached());
+    assertTrue(popup.isShowing());
+
+    popup.hide();
+    assertFalse(popup.isAttached());
+    assertFalse(popup.isShowing());
+  }
+
+  /**
+ * Test that showing a popup while it is hiding will not result in an illegal
    * state.
    */
   public void testShowWhileHiding() {

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to