Bug 1141756 - Part 1: Add null check for mPresShell in nsPrintEngine::GetSeqFrameAndCountPagesInternal. r=dholbert, a=jcristau
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -326,16 +326,25 @@ nsPrintEngine::InstallPrintPreviewListen
//----------------------------------------------------------------------
nsresult
nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
nsIFrame*& aSeqFrame,
int32_t& aCount)
{
NS_ENSURE_ARG_POINTER(aPO);
+ // This is sometimes incorrectly called before the pres shell has been created
+ // (bug 1141756). MOZ_DIAGNOSTIC_ASSERT so we'll still see the crash in
+ // Nightly/Aurora in case the other patch fixes this.
+ if (!aPO->mPresShell) {
+ MOZ_DIAGNOSTIC_ASSERT(false,
+ "GetSeqFrameAndCountPages needs a non-null pres shell");
+ return NS_ERROR_FAILURE;
+ }
+
// Finds the SimplePageSequencer frame
nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
aSeqFrame = do_QueryFrame(seqFrame);
if (!aSeqFrame) {
return NS_ERROR_FAILURE;
}
// count the total number of pages