summaryrefslogtreecommitdiffstats
path: root/src/pdf
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-02-07 16:43:58 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-03-07 17:41:03 +0100
commit0b96fe3a5ed7f4cfd2ceda5a5eb9f471239ce33d (patch)
treebf686b5d642f0c01b5893c30faa1b058c25c5cd7 /src/pdf
parentaf5483e35a604cfe08e712235113bac0a0c07a56 (diff)
QPdfDocument: avoid setStatus(error) before certainty of which error
When a document requires a password, we will first see PDF_DATA_NOTAVAIL, but we should not call setStatus(QPdfDocument::Error) yet, because updateLastError() will discover that it requires a password immediately afterwards. This avoids showing the user an incorrect error dialog. Amends 9968e2578f96081d2a242340620fcb2b96d9a1d3 Change-Id: I2216017d417bb0bad707900ce8c745363a396d7d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/qpdfdocument.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp
index f442c1ebf..b65504088 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -153,6 +153,8 @@ void QPdfDocumentPrivate::updateLastError()
default:
Q_UNREACHABLE();
}
+ if (lastError != QPdfDocument::NoError)
+ qCDebug(qLcDoc) << "FPDF error" << error << "->" << lastError;
}
void QPdfDocumentPrivate::load(QIODevice *newDevice, bool transferDeviceOwnership)
@@ -284,10 +286,9 @@ void QPdfDocumentPrivate::tryLoadDocument()
case PDF_DATA_NOTAVAIL:
qCDebug(qLcDoc) << "data not yet available";
lastError = QPdfDocument::DataNotYetAvailableError;
- setStatus(QPdfDocument::Error);
break;
case PDF_DATA_AVAIL:
- // all good
+ lastError = QPdfDocument::NoError;
break;
}
@@ -297,6 +298,8 @@ void QPdfDocumentPrivate::tryLoadDocument()
lock.unlock();
updateLastError();
+ if (lastError != QPdfDocument::NoError)
+ setStatus(QPdfDocument::Error);
if (lastError == QPdfDocument::IncorrectPasswordError) {
FPDF_CloseDocument(doc);