From b700f65011eaecefc60f6a4760547ecfb5542e34 Mon Sep 17 00:00:00 2001
From: Shawn Rutledge <shawn.rutledge@qt.io>
Date: Mon, 3 Feb 2020 16:54:40 +0100
Subject: [PATCH] QPdfDocumentPrivate::load(): check the first two pages

This seems to make QPdfLinkModel happy for some reason; otherwise
QPdfLinkModelPrivate::update() does not succeed in getting page numbers
when it calls FPDFDest_GetDestPageIndex().
Amends 9231d3444555945297857ee4aae05919083ea479

Change-Id: Iaed3301a1ab304ac9813c3b605b2f9c7465bf8e7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
---
 src/pdf/qpdfdocument.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp
index 69dc6e9ad..3719938a2 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -211,8 +211,9 @@ void QPdfDocumentPrivate::load(QIODevice *newDevice, bool transferDeviceOwnershi
             emit q->pageCountChanged(pageCount);
         }
 
-        // If it's a local file, and the first page is available, probably the whole document is available.
-        if (checkPageComplete(0)) {
+        // If it's a local file, and the first couple of pages are available,
+        // probably the whole document is available.
+        if (checkPageComplete(0) && (pageCount < 2 || checkPageComplete(1))) {
             setStatus(QPdfDocument::Ready);
         } else {
             updateLastError();
-- 
GitLab