From e62e6b77818b4f25a796abea4c8679743e71cf45 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Wed, 24 Aug 2016 14:10:09 +0200 Subject: Fix loading of large PDF documents Call FPDFAvail_IsPageAvail multiple times and check return value, otherwise the page won't be loaded completely. Change-Id: I9a6de3443eec6819be9b6eaa2a5b054329da4f80 Reviewed-by: Simon Hausmann --- src/pdf/qpdfdocument.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp index 3ef947f..709c702 100644 --- a/src/pdf/qpdfdocument.cpp +++ b/src/pdf/qpdfdocument.cpp @@ -251,9 +251,15 @@ void QPdfDocumentPrivate::checkComplete() QPdfMutexLocker lock; - for (int i = 0, count = FPDF_GetPageCount(doc); i < count; ++i) - if (!FPDFAvail_IsPageAvail(avail, i, this)) + for (int i = 0, count = FPDF_GetPageCount(doc); i < count; ++i) { + int result = PDF_DATA_NOTAVAIL; + while (result == PDF_DATA_NOTAVAIL) { + result = FPDFAvail_IsPageAvail(avail, i, this); + } + + if (result == PDF_DATA_ERROR) loadComplete = false; + } lock.unlock(); -- cgit v1.2.3