Bug 429315. Don't reparent toplevel widgets when we reparent a view subtree; they should remain toplevel. r+sr=bzbarsky,a=beltzner
authorroc+@cs.cmu.edu
Thu, 17 Apr 2008 01:17:06 -0700
changeset 14409 4cb89907d5abffb91656479f72ed7ed90738ced8
parent 14408 5e2ffdbabafdb87f9652c0a1e66931386c5ecbf8
child 14410 fc30f69feef6c6a49d62ca246ce44cbcf7cfa76f
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs429315
milestone1.9pre
Bug 429315. Don't reparent toplevel widgets when we reparent a view subtree; they should remain toplevel. r+sr=bzbarsky,a=beltzner
view/src/nsViewManager.cpp
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1423,17 +1423,18 @@ void nsViewManager::ReparentChildWidgets
 {
   if (aView->HasWidget()) {
     // Check to see if the parent widget is the
     // same as the new parent. If not then reparent
     // the widget, otherwise there is nothing more
     // to do for the view and its descendants
     nsIWidget* widget = aView->GetWidget();
     nsIWidget* parentWidget = widget->GetParent();
-    if (parentWidget != aNewWidget) {
+    // Toplevel widgets should not be reparented!
+    if (parentWidget && parentWidget != aNewWidget) {
 #ifdef DEBUG
       nsresult rv =
 #endif
         widget->SetParent(aNewWidget);
       NS_ASSERTION(NS_SUCCEEDED(rv), "SetParent failed!");
     }
     return;
   }