Bug 616300 crash [@ nsPrintEngine::DoCommonPrint(int, nsIPrintSettings*, nsIWebProgressListener*)]
authortimeless@mozdev.org
Sun, 05 Dec 2010 10:16:01 +0000
changeset 58621 916b65373ba2a667de38d81290876987be58d5da
parent 58620 48e4a07c0eda7de8b1b260efa8fb27e7845c6d24
child 58622 cc14f84709d4ae64e1d09df837dfc7e01cf1936f
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs616300
milestone2.0b8pre
Bug 616300 crash [@ nsPrintEngine::DoCommonPrint(int, nsIPrintSettings*, nsIWebProgressListener*)] r=roc, a=roc
layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -611,28 +611,36 @@ nsPrintEngine::DoCommonPrint(PRBool     
         // return NS_ERROR_NOT_IMPLEMENTED or an error code.
         //
         // NS_ERROR_NOT_IMPLEMENTED indicates they want default behavior
         // Any other error code means we must bail out
         //
         nsCOMPtr<nsIWebBrowserPrint> wbp(do_QueryInterface(mDocViewerPrint));
         rv = printPromptService->ShowPrintDialog(domWin, wbp,
                                                  mPrt->mPrintSettings);
-        if (rv == NS_ERROR_NOT_IMPLEMENTED) {
-          // This means the Dialog service was there, 
-          // but they choose not to implement this dialog and 
-          // are looking for default behavior from the toolkit
-          rv = NS_OK;
-        } else if (NS_SUCCEEDED(rv)) {
+        //
+        // ShowPrintDialog triggers an event loop which means we can't assume
+        // that the state of this->{anything} matches the state we've checked
+        // above. Including that a given {thing} is non null.
+
+        if (NS_SUCCEEDED(rv)) {
           // since we got the dialog and it worked then make sure we 
           // are telling GFX we want to print silent
           printSilently = PR_TRUE;
+
+          if (mPrt && mPrt->mPrintSettings) {
+            // The user might have changed shrink-to-fit in the print dialog, so update our copy of its state
+            mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit);
+          }
+        } else if (rv == NS_ERROR_NOT_IMPLEMENTED) {
+          // This means the Dialog service was there,
+          // but they choose not to implement this dialog and
+          // are looking for default behavior from the toolkit
+          rv = NS_OK;
         }
-        // The user might have changed shrink-to-fit in the print dialog, so update our copy of its state
-        mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit);
       } else {
         rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE;
       }
     } else {
       // Call any code that requires a run of the event loop.
       rv = mPrt->mPrintSettings->SetupSilentPrinting();
     }
     // Check explicitly for abort because it's expected