1
0
forked from pool/libqt5-qtbase

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
This commit is contained in:
Dominique Leuenberger 2019-06-12 11:05:30 +00:00 committed by Git OBS Bridge
parent 493d665297
commit aa53756637
3 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,122 @@
From 1d4523091db7e83e895f5a392bb43b02d0367658 Mon Sep 17 00:00:00 2001
From: Lars Knoll <lars.knoll@qt.io>
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 <simon.hausmann@qt.io>
---
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 = "<img src=\"data://test.png\">";
+ 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 = "<img src=\"data://test.png\">";
+ 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 = "<img src=\"data://test.png\">";
+ 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 = "<img src=\"data://test.png\">";
+ document.setHtml(html);
+
+ QCOMPARE(document.pageCount(), 2);
+ }
+}
+
QTEST_MAIN(tst_QTextDocumentLayout)
#include "tst_qtextdocumentlayout.moc"
--
2.21.0

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri May 31 22:33:07 UTC 2019 - Fabian Vogt <fabian@ritter-vogt.de>
- 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 <mliska@suse.cz>
- Disable LTO (boo#1133242).
-------------------------------------------------------------------
Thu Apr 18 07:26:30 UTC 2019 - fabian@ritter-vogt.de

View File

@ -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