Bug 1323777 part 2 - make PresShell::Destroy() return immediately if it's already been called. r=smaug
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1147,16 +1147,21 @@ LogTextPerfStats(gfxTextPerfMetrics* aTe
aCounts.genericLookups,
aTextPerf->cumulative.textrunDestr));
}
}
void
PresShell::Destroy()
{
+ // Do not add code before this line please!
+ if (mHaveShutDown) {
+ return;
+ }
+
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"destroy called on presshell while scripts not blocked");
// dump out cumulative text perf metrics
gfxTextPerfMetrics* tp;
if (mPresContext && (tp = mPresContext->GetTextPerfMetrics())) {
tp->Accumulate();
if (tp->cumulative.numChars > 0) {
@@ -1181,19 +1186,16 @@ PresShell::Destroy()
#ifdef MOZ_REFLOW_PERF
DumpReflows();
if (mReflowCountMgr) {
delete mReflowCountMgr;
mReflowCountMgr = nullptr;
}
#endif
- if (mHaveShutDown)
- return;
-
if (mZoomConstraintsClient) {
mZoomConstraintsClient->Destroy();
mZoomConstraintsClient = nullptr;
}
if (mMobileViewportManager) {
mMobileViewportManager->Destroy();
mMobileViewportManager = nullptr;
}