From 1383db2ceacae76d46164809f50cc26dbd1a71ea Mon Sep 17 00:00:00 2001 From: "sharparrow1@yahoo.com" Date: Thu, 12 Jul 2007 16:19:47 -0700 Subject: [PATCH] Bug 347743 related fix: make SetParent actually change the parent of the widget. r+sr=roc. --- widget/src/windows/nsWindow.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 69d74058d63..93fe035336b 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/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; }