Bug 803255. Ensure previous document viewer is cleared when creating a new one to avoid leaking the old one. r=bz
authorFelipe Gomes <felipc@gmail.com>
Mon, 12 Nov 2012 13:00:19 -0800
changeset 113010 bd5af10962327f5d114dd30615945c7cc0d6a200
parent 113009 30df269639f0d4e270657e1e614d5f984d5d69c6
child 113011 769777308b198b158e3efae2659347d3305c3798
push id23847
push userphilringnalda@gmail.com
push dateTue, 13 Nov 2012 05:07:25 +0000
treeherdermozilla-central@1b0226622e94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs803255
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 803255. Ensure previous document viewer is cleared when creating a new one to avoid leaking the old one. r=bz
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -904,16 +904,22 @@ DocumentViewerImpl::InitInternal(nsIWidg
                                                                &pageHeight);
         mPresContext->SetPageSize(
           nsSize(mPresContext->CSSTwipsToAppUnits(NSToIntFloor(pageWidth)),
                  mPresContext->CSSTwipsToAppUnits(NSToIntFloor(pageHeight))));
         mPresContext->SetIsRootPaginatedDocument(true);
         mPresContext->SetPageScale(1.0f);
       }
 #endif
+    } else {
+      // Avoid leaking the old viewer.
+      if (mPreviousViewer) {
+        mPreviousViewer->Destroy();
+        mPreviousViewer = nullptr;
+      }
     }
   }
 
   nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryReferent(mContainer));
   if (requestor) {
     if (mPresContext) {
       nsCOMPtr<nsILinkHandler> linkHandler;
       requestor->GetInterface(NS_GET_IID(nsILinkHandler),