Skip to content

Commit

Permalink
Bug 1265795 P4 Always call nsDocument::SetScriptGlobalObject(nullptr)…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
wanderview committed Apr 21, 2016
1 parent e82b417 commit 5f9ee89
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8943,6 +8943,7 @@ nsDocument::Destroy()

mIsGoingAway = true;

SetScriptGlobalObject(nullptr);
RemovedFromDocShell();

bool oldVal = mInUnlinkOrDeletion;
Expand Down
2 changes: 0 additions & 2 deletions layout/base/nsDocumentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,6 @@ nsDocumentViewer::SetDocumentInternal(nsIDocument* aDocument,
}

if (mDocument->IsStaticDocument()) {
mDocument->SetScriptGlobalObject(nullptr);
mDocument->Destroy();
}

Expand Down Expand Up @@ -4306,7 +4305,6 @@ nsDocumentViewer::OnDonePrinting()
}
} else if (mClosingWhilePrinting) {
if (mDocument) {
mDocument->SetScriptGlobalObject(nullptr);
mDocument->Destroy();
mDocument = nullptr;
}
Expand Down

0 comments on commit 5f9ee89

Please sign in to comment.