Bug 1323777 part 2 - make PresShell::Destroy() return immediately if it's already been called. r=smaug
authorMats Palmgren <mats@mozilla.com>
Wed, 25 Jan 2017 23:34:03 +0200
changeset 466640 65fb78694c3a51dafac29cb886cfc2bdb8b4a301
parent 466639 581720c25bf0f91392e45d106a4baf96e88575f9
child 466641 021414da3a4c813770106d915107686ac2d5310b
push id42948
push userbmo:gasolin@mozilla.com
push dateThu, 26 Jan 2017 07:49:21 +0000
reviewerssmaug
bugs1323777
milestone54.0a1
Bug 1323777 part 2 - make PresShell::Destroy() return immediately if it's already been called. r=smaug
layout/base/PresShell.cpp
--- 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;
   }