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
Родитель e6b1bfa615
Коммит b48fe04ebd
4 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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