Bug 627938: Fix nsGlobalChromeWindow cleanup. (r=smaug, a=jst)

This commit is contained in:
Chris Leary 2011-01-23 11:51:00 -08:00
parent b803e3260c
commit 2c15096ee5
2 changed files with 26 additions and 4 deletions

View File

@ -799,6 +799,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mFireOfflineStatusChangeEventOnThaw(PR_FALSE),
mCreatingInnerWindow(PR_FALSE),
mIsChrome(PR_FALSE),
mCleanMessageManager(PR_FALSE),
mNeedsFocus(PR_TRUE),
mHasFocus(PR_FALSE),
#if defined(XP_MAC) || defined(XP_MACOSX)
@ -1117,10 +1118,13 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog)
DisableAccelerationUpdates();
mHasAcceleration = PR_FALSE;
if (mIsChrome && static_cast<nsGlobalChromeWindow*>(this)->mMessageManager) {
static_cast<nsFrameMessageManager*>(
static_cast<nsGlobalChromeWindow*>(
this)->mMessageManager.get())->Disconnect();
if (mCleanMessageManager) {
NS_ABORT_IF_FALSE(mIsChrome, "only chrome should have msg manager cleaned");
nsGlobalChromeWindow *asChrome = static_cast<nsGlobalChromeWindow*>(this);
if (asChrome->mMessageManager) {
static_cast<nsFrameMessageManager*>(
asChrome->mMessageManager.get())->Disconnect();
}
}
mInnerWindowHolder = nsnull;

View File

@ -863,6 +863,11 @@ protected:
// Fast way to tell if this is a chrome window (without having to QI).
PRPackedBool mIsChrome : 1;
// Hack to indicate whether a chrome window needs its message manager
// to be disconnected, since clean up code is shared in the global
// window superclass.
PRPackedBool mCleanMessageManager : 1;
// Indicates that the current document has never received a document focus
// event.
PRPackedBool mNeedsFocus : 1;
@ -1004,6 +1009,19 @@ public:
: nsGlobalWindow(aOuterWindow)
{
mIsChrome = PR_TRUE;
mCleanMessageManager = PR_TRUE;
}
~nsGlobalChromeWindow()
{
NS_ABORT_IF_FALSE(mCleanMessageManager,
"chrome windows may always disconnect the msg manager");
if (mMessageManager) {
static_cast<nsFrameMessageManager *>(
mMessageManager.get())->Disconnect();
}
mCleanMessageManager = PR_FALSE;
}
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsGlobalChromeWindow,