Bug 616300 crash [@ nsPrintEngine::DoCommonPrint(int, nsIPrintSettings*, nsIWebProgressListener*)]
r=roc, a=roc
--- 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