From aa537566378cfbb82c6887e2a4506f6cc6db4d23654bd33a80c0ec22d742de1e Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Wed, 12 Jun 2019 11:05:30 +0000 Subject: [PATCH] Accepting request 706812 from KDE:Qt5 - Add patch to fix layouting of certain text documents (QTBUG-73730): * 0001-Fix-page-breaking-with-large-images.patch - Disable LTO (boo#1133242). OBS-URL: https://build.opensuse.org/request/show/706812 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=96 --- ...-Fix-page-breaking-with-large-images.patch | 122 ++++++++++++++++++ libqt5-qtbase.changes | 11 ++ libqt5-qtbase.spec | 2 + 3 files changed, 135 insertions(+) create mode 100644 0001-Fix-page-breaking-with-large-images.patch diff --git a/0001-Fix-page-breaking-with-large-images.patch b/0001-Fix-page-breaking-with-large-images.patch new file mode 100644 index 0000000..843e0f7 --- /dev/null +++ b/0001-Fix-page-breaking-with-large-images.patch @@ -0,0 +1,122 @@ +From 1d4523091db7e83e895f5a392bb43b02d0367658 Mon Sep 17 00:00:00 2001 +From: Lars Knoll +Date: Fri, 26 Apr 2019 09:15:52 +0200 +Subject: [PATCH] Fix page breaking with large images + +Don't go into an infinite loop breaking pages, when an image is about +as large as the page. Correctly take top and bottom margins into account +when calculating whether the image could fit on one page. + +Amends change 416b4cf685030114837bd375664fd12047895a62. + +Fixes: QTBUG-73730 +Change-Id: Id311ddf05510be3b1d131702f4e17025a9861e58 +Reviewed-by: Simon Hausmann +--- + src/gui/text/qtextdocumentlayout.cpp | 5 +- + .../tst_qtextdocumentlayout.cpp | 60 +++++++++++++++++++ + 2 files changed, 64 insertions(+), 1 deletion(-) + +diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp +index 2e1a2b5bff..bed0a2c450 100644 +--- a/src/gui/text/qtextdocumentlayout.cpp ++++ b/src/gui/text/qtextdocumentlayout.cpp +@@ -145,6 +145,9 @@ struct QTextLayoutStruct { + inline QFixed absoluteY() const + { return frameY + y; } + ++ inline QFixed contentHeight() const ++ { return pageHeight - pageBottomMargin - pageTopMargin; } ++ + inline int currentPage() const + { return pageHeight == 0 ? 0 : (absoluteY() / pageHeight).truncate(); } + +@@ -2701,7 +2704,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi + getLineHeightParams(blockFormat, line, scaling, &lineAdjustment, &lineBreakHeight, &lineHeight, &lineBottom); + + while (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom && +- layoutStruct->pageHeight >= lineBreakHeight) { ++ layoutStruct->contentHeight() >= lineBreakHeight) { + layoutStruct->newPage(); + + floatMargins(layoutStruct->y, layoutStruct, &left, &right); +diff --git a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +index c79f787547..f66b16b970 100644 +--- a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp ++++ b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +@@ -59,6 +59,8 @@ private slots: + void imageAtRightAlignedTab(); + void blockVisibility(); + ++ void largeImage(); ++ + private: + QTextDocument *doc; + }; +@@ -347,5 +349,63 @@ void tst_QTextDocumentLayout::blockVisibility() + QCOMPARE(doc->size(), halfSize); + } + ++void tst_QTextDocumentLayout::largeImage() ++{ ++ auto img = QImage(400, 500, QImage::Format_ARGB32_Premultiplied); ++ img.fill(Qt::black); ++ ++ { ++ QTextDocument document; ++ ++ document.addResource(QTextDocument::ImageResource, ++ QUrl("data://test.png"), QVariant(img)); ++ document.setPageSize({500, 504}); ++ ++ auto html = ""; ++ document.setHtml(html); ++ ++ QCOMPARE(document.pageCount(), 2); ++ } ++ ++ { ++ QTextDocument document; ++ ++ document.addResource(QTextDocument::ImageResource, ++ QUrl("data://test.png"), QVariant(img)); ++ document.setPageSize({500, 508}); ++ ++ auto html = ""; ++ document.setHtml(html); ++ ++ QCOMPARE(document.pageCount(), 1); ++ } ++ ++ { ++ QTextDocument document; ++ ++ document.addResource(QTextDocument::ImageResource, ++ QUrl("data://test.png"), QVariant(img)); ++ document.setPageSize({585, 250}); ++ ++ auto html = ""; ++ document.setHtml(html); ++ ++ QCOMPARE(document.pageCount(), 3); ++ } ++ ++ { ++ QTextDocument document; ++ ++ document.addResource(QTextDocument::ImageResource, ++ QUrl("data://test.png"), QVariant(img)); ++ document.setPageSize({585, 258}); ++ ++ auto html = ""; ++ document.setHtml(html); ++ ++ QCOMPARE(document.pageCount(), 2); ++ } ++} ++ + QTEST_MAIN(tst_QTextDocumentLayout) + #include "tst_qtextdocumentlayout.moc" +-- +2.21.0 + diff --git a/libqt5-qtbase.changes b/libqt5-qtbase.changes index 12a6d3b..a9e9d1e 100644 --- a/libqt5-qtbase.changes +++ b/libqt5-qtbase.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Fri May 31 22:33:07 UTC 2019 - Fabian Vogt + +- Add patch to fix layouting of certain text documents (QTBUG-73730): + * 0001-Fix-page-breaking-with-large-images.patch + +------------------------------------------------------------------- +Thu Apr 25 07:37:27 UTC 2019 - Martin Liška + +- Disable LTO (boo#1133242). + ------------------------------------------------------------------- Thu Apr 18 07:26:30 UTC 2019 - fabian@ritter-vogt.de diff --git a/libqt5-qtbase.spec b/libqt5-qtbase.spec index 52a71a9..8f1a3e4 100644 --- a/libqt5-qtbase.spec +++ b/libqt5-qtbase.spec @@ -77,6 +77,7 @@ Patch22: 0002-Revert-qtlite-Fix-build-libs-with-no-feature-regular.patch Patch23: 0003-Revert-White-list-more-recent-Mesa-version-for-multi.patch Patch24: fix-fixqt4headers.patch # patches 1000-2000 and above from upstream 5.12 branch # +Patch1000: 0001-Fix-page-breaking-with-large-images.patch # patches 2000-3000 and above from upstream 5.13/dev branch # Patch2000: reproducible-qrc-time.patch @@ -823,6 +824,7 @@ Recommends: libqt5-qtbase-devel Examples for the libqt5-qtbase modules. %build +%define _lto_cflags %{nil} %ifarch ppc64 RPM_OPT_FLAGS="%{optflags} -mminimal-toc" %endif