Bug 1323777 - Make PresShell::Destroy() return immediately if it's already been called. r=smaug, a=gchang
authorMats Palmgren <mats@mozilla.com>
Wed, 25 Jan 2017 23:34:03 +0200
changeset 375973 66bd19aeb873560c559abe5f1f380647ea50b2d7
parent 375972 bd48d1daf4c229ce5b7e554aea75de5a1fff7e08
child 375974 d70c225f090a0afb137102cbe1e68919e92d8128
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, gchang
bugs1323777
milestone53.0a2
Bug 1323777 - Make PresShell::Destroy() return immediately if it's already been called. r=smaug, a=gchang
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1075,16 +1075,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) {
@@ -1109,19 +1114,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;
   }