diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 07911c9f144..291475c4f0c 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -3770,13 +3770,28 @@ DocumentViewerImpl::InstallNewPresentation() } //------------------------------------------------------------ +// This called ONLY when printing has completed and the DV +// is being notified that it should get rid of the PrintEngine. +// +// BUT, if we are in Print Preview then we want to ignore the +// notification (we do not get rid of the PrintEngine) +// +// One small caveat: +// This IS called from two places in this module for cleaning +// up when an error occurred during the start up printing +// and print preview +// void DocumentViewerImpl::OnDonePrinting() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) if (mPrintEngine) { - mPrintEngine->Destroy(); - NS_RELEASE(mPrintEngine); + if (GetIsPrintPreview()) { + mPrintEngine->DestroyPrintingData(); + } else { + mPrintEngine->Destroy(); + NS_RELEASE(mPrintEngine); + } } #endif // NS_PRINTING && NS_PRINT_PREVIEW } diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 6d6b9ca1cb7..79efdb74da6 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -316,6 +316,15 @@ void nsPrintEngine::Destroy() } +//------------------------------------------------------- +void nsPrintEngine::DestroyPrintingData() +{ + if (mPrt) { + delete mPrt; + mPrt = nsnull; + } +} + //--------------------------------------------------------------------------------- //-- Section: Methods needed by the DocViewer //--------------------------------------------------------------------------------- @@ -2237,10 +2246,6 @@ nsresult nsPrintEngine::CleanupOnFailure(nsresult aResult, PRBool aIsPrinting) NS_RELEASE(mPagePrintTimer); } - //if (mPrt) { - // delete mPrt; - // mPrt = nsnull; - //} SetIsPrinting(PR_FALSE); /* cleanup done, let's fire-up an error dialog to notify the user diff --git a/mozilla/content/base/src/nsPrintEngine.h b/mozilla/content/base/src/nsPrintEngine.h index afc3095ba30..91a2cfb0639 100644 --- a/mozilla/content/base/src/nsPrintEngine.h +++ b/mozilla/content/base/src/nsPrintEngine.h @@ -107,9 +107,10 @@ public: nsPrintEngine(); - ~nsPrintEngine(); // non-virtual + virtual ~nsPrintEngine(); void Destroy(); + void DestroyPrintingData(); nsresult Initialize(nsIDocumentViewer* aDocViewer, nsIDocumentViewerPrint* aDocViewerPrint, diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 07911c9f144..291475c4f0c 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -3770,13 +3770,28 @@ DocumentViewerImpl::InstallNewPresentation() } //------------------------------------------------------------ +// This called ONLY when printing has completed and the DV +// is being notified that it should get rid of the PrintEngine. +// +// BUT, if we are in Print Preview then we want to ignore the +// notification (we do not get rid of the PrintEngine) +// +// One small caveat: +// This IS called from two places in this module for cleaning +// up when an error occurred during the start up printing +// and print preview +// void DocumentViewerImpl::OnDonePrinting() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) if (mPrintEngine) { - mPrintEngine->Destroy(); - NS_RELEASE(mPrintEngine); + if (GetIsPrintPreview()) { + mPrintEngine->DestroyPrintingData(); + } else { + mPrintEngine->Destroy(); + NS_RELEASE(mPrintEngine); + } } #endif // NS_PRINTING && NS_PRINT_PREVIEW } diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 6d6b9ca1cb7..79efdb74da6 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -316,6 +316,15 @@ void nsPrintEngine::Destroy() } +//------------------------------------------------------- +void nsPrintEngine::DestroyPrintingData() +{ + if (mPrt) { + delete mPrt; + mPrt = nsnull; + } +} + //--------------------------------------------------------------------------------- //-- Section: Methods needed by the DocViewer //--------------------------------------------------------------------------------- @@ -2237,10 +2246,6 @@ nsresult nsPrintEngine::CleanupOnFailure(nsresult aResult, PRBool aIsPrinting) NS_RELEASE(mPagePrintTimer); } - //if (mPrt) { - // delete mPrt; - // mPrt = nsnull; - //} SetIsPrinting(PR_FALSE); /* cleanup done, let's fire-up an error dialog to notify the user diff --git a/mozilla/layout/printing/nsPrintEngine.h b/mozilla/layout/printing/nsPrintEngine.h index afc3095ba30..91a2cfb0639 100644 --- a/mozilla/layout/printing/nsPrintEngine.h +++ b/mozilla/layout/printing/nsPrintEngine.h @@ -107,9 +107,10 @@ public: nsPrintEngine(); - ~nsPrintEngine(); // non-virtual + virtual ~nsPrintEngine(); void Destroy(); + void DestroyPrintingData(); nsresult Initialize(nsIDocumentViewer* aDocViewer, nsIDocumentViewerPrint* aDocViewerPrint,