Bug 1265795 P4 Always call nsDocument::SetScriptGlobalObject(nullptr) from nsDocument::Destroy(). r=bz

Currently there are certain paths in nsDocumentViewer that can call
nsDocument::Destroy(), but fail to call SetScriptGlobalObject(nullptr).  This
results in the global never being cleared.

This patch refactors things so nsDocument::Destroy() always clears the global.
This ensures a more consistent document teardown since we don't rely on
external callers to get multiple method calls correct.
This commit is contained in:
Ben Kelly 2016-04-21 16:10:40 -07:00
parent d78f4aec16
commit 67cfa5a9ee
2 changed files with 1 additions and 2 deletions

View File

@ -8943,6 +8943,7 @@ nsDocument::Destroy()
mIsGoingAway = true;
SetScriptGlobalObject(nullptr);
RemovedFromDocShell();
bool oldVal = mInUnlinkOrDeletion;

View File

@ -1758,7 +1758,6 @@ nsDocumentViewer::SetDocumentInternal(nsIDocument* aDocument,
}
if (mDocument->IsStaticDocument()) {
mDocument->SetScriptGlobalObject(nullptr);
mDocument->Destroy();
}
@ -4306,7 +4305,6 @@ nsDocumentViewer::OnDonePrinting()
}
} else if (mClosingWhilePrinting) {
if (mDocument) {
mDocument->SetScriptGlobalObject(nullptr);
mDocument->Destroy();
mDocument = nullptr;
}