Bug 347743 related fix: make SetParent actually change the parent of the widget. r+sr=roc.

This commit is contained in:
sharparrow1@yahoo.com 2007-07-12 16:19:47 -07:00
parent 3745d28e95
commit 1383db2cea

View File

@ -1636,9 +1636,20 @@ NS_METHOD nsWindow::Destroy()
NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent)
{
if (aNewParent) {
nsCOMPtr<nsIWidget> 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;
}