Bug 830236 - Add re-entrancy protection in a few places to avoid destroying things twice. r=cam

This commit is contained in:
Mats Palmgren 2013-01-15 21:47:10 +01:00
parent c78dc46a87
commit 97f9bf1fe4
4 changed files with 15 additions and 6 deletions

View File

@ -4262,11 +4262,12 @@ nsDocumentViewer::OnDonePrinting()
{
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
if (mPrintEngine) {
nsRefPtr<nsPrintEngine> pe = mPrintEngine;
mPrintEngine = nullptr;
if (GetIsPrintPreview()) {
mPrintEngine->DestroyPrintingData();
pe->DestroyPrintingData();
} else {
mPrintEngine->Destroy();
mPrintEngine = nullptr;
pe->Destroy();
}
// We are done printing, now cleanup

View File

@ -239,7 +239,8 @@ nsPrintEngine::nsPrintEngine() :
mOldPrtPreview(nullptr),
mDebugFile(nullptr),
mLoadCounter(0),
mDidLoadDataForPrinting(false)
mDidLoadDataForPrinting(false),
mIsDestroying(false)
{
}
@ -252,6 +253,11 @@ nsPrintEngine::~nsPrintEngine()
//-------------------------------------------------------
void nsPrintEngine::Destroy()
{
if (mIsDestroying) {
return;
}
mIsDestroying = true;
if (mPrt) {
delete mPrt;
mPrt = nullptr;

View File

@ -280,6 +280,7 @@ protected:
int32_t mLoadCounter;
bool mDidLoadDataForPrinting;
bool mIsDestroying;
nsresult AfterNetworkPrint(bool aHandleError);

View File

@ -113,10 +113,11 @@ nsPrintObject::DestroyPresentation()
#endif
mPresShell->EndObservingDocument();
nsAutoScriptBlocker scriptBlocker;
mPresShell->Destroy();
nsCOMPtr<nsIPresShell> shell = mPresShell;
mPresShell = nullptr;
shell->Destroy();
}
mPresContext = nullptr;
mPresShell = nullptr;
mViewManager = nullptr;
}