From 33c9bca79c6d3305e8fbc66e77946cb4e6c25bcc Mon Sep 17 00:00:00 2001 From: "sharparrow1%yahoo.com" Date: Thu, 12 Jul 2007 23:19:47 +0000 Subject: [PATCH] Bug 347743 related fix: make SetParent actually change the parent of the widget. r+sr=roc. git-svn-id: svn://10.0.0.236/trunk@229856 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/windows/nsWindow.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 69d74058d63..93fe035336b 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -1636,9 +1636,20 @@ NS_METHOD nsWindow::Destroy() NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent) { if (aNewParent) { + nsCOMPtr kungFuDeathGrip(this); + + nsIWidget* parent = GetParent(); + if (parent) { + parent->RemoveChild(this); + } + HWND newParent = (HWND)aNewParent->GetNativeData(NS_NATIVE_WINDOW); NS_ASSERTION(newParent, "Parent widget has a null native window handle"); - ::SetParent(mWnd, newParent); + if (newParent && mWnd) { + ::SetParent(mWnd, newParent); + } + + aNewParent->AddChild(this); return NS_OK; }