Bug 398265, Crash [@ nsPrintPreviewListener::RemoveListeners()] with <frame> on print preview, r+sr=roc, a=1.9+
authorOlli.Pettay@helsinki.fi
Fri, 09 Nov 2007 14:38:46 -0800
changeset 7782 aa8b9db86c75e467a2a39ae2cf48942b8a85d768
parent 7781 4fb15a064eaca17dbceaa5668a7809a198f21521
child 7783 58cb052cc87da54bde531a07dd74619c81ce5eeb
push idunknown
push userunknown
push dateunknown
reviewers1.9
bugs398265
milestone1.9b2pre
Bug 398265, Crash [@ nsPrintPreviewListener::RemoveListeners()] with <frame> on print preview, r+sr=roc, a=1.9+
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -3024,17 +3024,17 @@ nsPrintEngine::FinishPrintPreview()
   /* cleaup on failure + notify user */
   if (NS_FAILED(rv)) {
     /* cleanup done, let's fire-up an error dialog to notify the user
      * what went wrong...
      */
     mPrt->OnEndPrinting();
     TurnScriptingOn(PR_TRUE);
 
-    return CleanupOnFailure(rv, PR_FALSE); // ignore return value here
+    return rv;
   }
 
   // At this point we are done preparing everything
   // before it is to be created
 
 
   if (mIsDoingPrintPreview && mOldPrtPreview) {
     delete mOldPrtPreview;
@@ -3089,16 +3089,19 @@ nsPrintEngine::Observe(nsISupports *aSub
     rv = DocumentReadyForPrinting();
  
     /* cleaup on failure + notify user */
     if (NS_FAILED(rv)) {
       CleanupOnFailure(rv, PR_TRUE);
     }
   } else {
     rv = FinishPrintPreview();
+    if (NS_FAILED(rv)) {
+      CleanupOnFailure(rv, PR_FALSE);
+    }
     if (mPrtPreview) {
       mPrtPreview->OnEndPrinting();
     }
     rv = NS_OK;
   }
 
   return rv;
 
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -142,16 +142,18 @@ public:
 
   nsresult ReflowPrintObject(nsPrintObject * aPO);
 
   void CheckForChildFrameSets(nsPrintObject* aPO);
 
   void CalcNumPrintablePages(PRInt32& aNumPages);
   void ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify);
   nsresult CleanupOnFailure(nsresult aResult, PRBool aIsPrinting);
+  // If FinishPrintPreview() fails, caller may need to reset the state of the
+  // object, for example by calling CleanupOnFailure().
   nsresult FinishPrintPreview();
   static void CloseProgressDialog(nsIWebProgressListener* aWebProgressListener);
   void SetDocAndURLIntoProgress(nsPrintObject* aPO,
                                 nsIPrintProgressParams* aParams);
   void ElipseLongString(PRUnichar *& aStr, const PRUint32 aLen, PRBool aDoFront);
   nsresult CheckForPrinters(nsIPrintSettings* aPrintSettings);
   void CleanupDocTitleArray(PRUnichar**& aArray, PRInt32& aCount);