Bug 1323777 - Make PresShell::Destroy() return immediately if it's already been called. r=smaug, a=jcristau
authorMats Palmgren <mats@mozilla.com>
Wed, 25 Jan 2017 23:34:03 +0200
changeset 480403 cd797ef148c3e3b2a153d0ace89c4d5bcbab8267
parent 480402 405ee5de06739ed6cf90e38b4f006e8dc47bfbd7
child 480404 f0969e1a9c3b83f34ed861c0a4c9c230fcd1639a
push id44524
push usermartin.thomson@gmail.com
push dateWed, 08 Feb 2017 05:10:11 +0000
reviewerssmaug, jcristau
bugs1323777
milestone52.0
Bug 1323777 - Make PresShell::Destroy() return immediately if it's already been called. r=smaug, a=jcristau
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1093,16 +1093,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) {
@@ -1127,19 +1132,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;
   }