From ffe88ed1b32224063c659dfda029b6398bb04c0a Mon Sep 17 00:00:00 2001 From: "martijn.martijn%gmail.com" Date: Wed, 28 Nov 2007 22:17:12 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20396024=20=EF=BF=BD=20Crash=20[@=20nsPrint?= =?UTF-8?q?Engine::DocumentReadyForPrinting]=20with=20testcase=20that=20se?= =?UTF-8?q?t=20print=20preview,=20then=20reloads=20the=20page,=20part=202,?= =?UTF-8?q?=20r=3Dsharparrow1,=20sr=3Droc,=20blocking1.9+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/base/nsDocumentViewer.cpp | 32 +++++----- layout/base/tests/Makefile.in | 1 + layout/base/tests/test_bug396024.html | 91 +++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 15 deletions(-) create mode 100755 layout/base/tests/test_bug396024.html diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 6919603234f..bd0677ab820 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1411,6 +1411,23 @@ DocumentViewerImpl::Destroy() } } +#ifdef NS_PRINTING + if (mPrintEngine) { + // This code was moved earlier to fix a crash when a document was + // destroyed while it was in print preview mode, see bug 396024 +#ifdef NS_PRINT_PREVIEW + PRBool doingPrintPreview; + mPrintEngine->GetDoingPrintPreview(&doingPrintPreview); + if (doingPrintPreview) { + mPrintEngine->FinishPrintPreview(); + } +#endif + + mPrintEngine->Destroy(); + mPrintEngine = nsnull; + } +#endif + Hide(); // This is after Hide() so that the user doesn't see the inputs clear. @@ -1470,21 +1487,6 @@ DocumentViewerImpl::Destroy() // destructor might never be called (especially if we're being // used from JS. -#ifdef NS_PRINTING - if (mPrintEngine) { -#ifdef NS_PRINT_PREVIEW - PRBool doingPrintPreview; - mPrintEngine->GetDoingPrintPreview(&doingPrintPreview); - if (doingPrintPreview) { - mPrintEngine->FinishPrintPreview(); - } -#endif - - mPrintEngine->Destroy(); - mPrintEngine = nsnull; - } -#endif - // Avoid leaking the old viewer. if (mPreviousViewer) { mPreviousViewer->Destroy(); diff --git a/layout/base/tests/Makefile.in b/layout/base/tests/Makefile.in index 5e917b2bea1..ac15ba8fa54 100644 --- a/layout/base/tests/Makefile.in +++ b/layout/base/tests/Makefile.in @@ -83,6 +83,7 @@ ifdef MOZ_MOCHITEST _TEST_FILES = \ test_bug66619.html \ test_bug388019.html \ + test_bug396024.html \ test_bug399284.html \ test_bug399951.html \ $(NULL) diff --git a/layout/base/tests/test_bug396024.html b/layout/base/tests/test_bug396024.html new file mode 100755 index 00000000000..0889da30b5f --- /dev/null +++ b/layout/base/tests/test_bug396024.html @@ -0,0 +1,91 @@ + + + + Test for Bug 396024 + + + + + +Mozilla Bug 396024 + +
+
+
+
+ + +