From 849e2fec660a6df9fac9b5245afd348528508518 Mon Sep 17 00:00:00 2001 From: Steven Michaud Date: Fri, 18 Jul 2008 10:54:12 -0500 Subject: [PATCH] Make sure Destroy() is called before an nsIWidget is destroyed. b=434089 r=bzbarsky sr=vladimir --- embedding/browser/webBrowser/nsWebBrowser.cpp | 7 +++++-- view/src/nsView.cpp | 1 + xpfe/appshell/src/nsWebShellWindow.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index ba9e31b43e7..b31ae17489c 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -132,8 +132,11 @@ PRBool PR_CALLBACK deleteListener(void *aElement, void *aData) { NS_IMETHODIMP nsWebBrowser::InternalDestroy() { - if (mInternalWidget) - mInternalWidget->SetClientData(0); + if (mInternalWidget) { + mInternalWidget->SetClientData(0); + mInternalWidget->Destroy(); + mInternalWidget = nsnull; // Force release here. + } SetDocShell(nsnull); diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index deff015d8a6..c390740c6a7 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -631,6 +631,7 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID, ViewWrapper* wrapper = GetWrapperFor(mWindow); NS_IF_RELEASE(wrapper); mWindow->SetClientData(nsnull); + mWindow->Destroy(); NS_RELEASE(mWindow); } diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 9b7149bd487..b3243a3db4b 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -146,9 +146,11 @@ nsWebShellWindow::~nsWebShellWindow() if (gFocusedWindowBeforeSuppression == this) { gFocusedWindowBeforeSuppression = nsnull; } - if (mWindow) + if (mWindow) { mWindow->SetClientData(0); - mWindow = nsnull; // Force release here. + mWindow->Destroy(); + mWindow = nsnull; // Force release here. + } if (mSPTimerLock) { PR_Lock(mSPTimerLock);