Bug 545330 - Crash [@ PresShell::Destroy] on exit after failed Print Preview of XUL document, r=mats
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 11 Feb 2010 13:02:38 +0200
changeset 38057 d532977c11bf7257c5c3ea7f0d1aaf2a880ccf48
parent 38056 af0f0615944e9a034879738101dcad03717ba485
child 38058 0068be50163313a2172ed974009d29c6818acab1
push id11594
push useropettay@mozilla.com
push dateThu, 11 Feb 2010 11:13:20 +0000
treeherdermozilla-central@0068be501633 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs545330
milestone1.9.3a2pre
Bug 545330 - Crash [@ PresShell::Destroy] on exit after failed Print Preview of XUL document, r=mats
layout/base/nsDocumentViewer.cpp
toolkit/components/printing/content/printUtils.js
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -4201,16 +4201,19 @@ DocumentViewerImpl::SetIsPrintPreview(PR
   // that way if anyone of them tries to "navigate" it can't
   if (mContainer) {
     nsCOMPtr<nsIDocShellTreeNode> docShellTreeNode(do_QueryReferent(mContainer));
     NS_ASSERTION(docShellTreeNode, "mContainer has to be a nsIDocShellTreeNode");
     SetIsPrintingInDocShellTree(docShellTreeNode, aIsPrintPreview, PR_TRUE);
   }
 #endif
   if (!aIsPrintPreview) {
+    if (mPresShell) {
+      DestroyPresShell();
+    }
     mWindow = nsnull;
     mViewManager = nsnull;
     mPresContext = nsnull;
     mPresShell = nsnull;
   }
 }
 
 //----------------------------------------------------------------------------------
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -230,16 +230,20 @@ var PrintUtils = {
       webBrowserPrint = this.getPrintPreview();
       webBrowserPrint.printPreview(printSettings, originalWindow,
                                    this._webProgressPP.value);
     } catch (e) {
       // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
       // causing an exception to be thrown which we catch here.
       // Unfortunately this will also consume helpful failures, so add a
       // dump(e); // if you need to debug
+
+      // Need to call enter and exit so that UI gets back to normal.
+      this._callback.onEnter();
+      this._callback.onExit();
       return;
     }
 
     var printPreviewTB = document.getElementById("print-preview-toolbar");
     if (printPreviewTB) {
       printPreviewTB.updateToolbar();
       var browser = this._callback.getPrintPreviewBrowser();
       browser.collapsed = false;