Bug 1655474 - Don't crash when trying to resume print while the page is closing. r=jwatt

This is a pre-existing issue that could already happen before the
regressing bug but seems worth addressing anyways.

If we're destroying we're definitely not going to be able to print, so
return an error rather than crashing in funny ways otherwise.

Depends on D85038

Differential Revision: https://phabricator.services.mozilla.com/D85039
This commit is contained in:
Emilio Cobos Álvarez 2020-07-28 22:00:45 +00:00
Родитель 4106c6fdd1
Коммит c51e748ab5
1 изменённых файлов: 8 добавлений и 0 удалений

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

@ -1372,6 +1372,10 @@ nsresult nsPrintJob::ReconstructAndReflow(bool doSetPixelScale) {
po->mPresContext->SetPrintPreviewScale(mScreenDPI / printDPI);
RefPtr<PresShell> presShell(po->mPresShell);
if (NS_WARN_IF(presShell->IsDestroying())) {
return NS_ERROR_FAILURE;
}
presShell->ReconstructFrames();
// If the printing was canceled or restarted with different data,
@ -1397,6 +1401,10 @@ nsresult nsPrintJob::ReconstructAndReflow(bool doSetPixelScale) {
presShell->FlushPendingNotifications(FlushType::Layout);
if (NS_WARN_IF(presShell->IsDestroying())) {
return NS_ERROR_FAILURE;
}
// If the printing was canceled or restarted with different data,
// let's stop doing this printing.
if (NS_WARN_IF(mPrt != printData)) {