diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-04-26 09:15:52 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-04-26 18:21:18 +0000 |
commit | b4cc29434769b1d6c08ab2fc76cdcc2dac5dede9 (patch) | |
tree | 735fc24efc4c5c419b6d6969b5bab06073f50f64 /src/gui/text/qtextdocumentlayout.cpp | |
parent | 78c84c6353257a477efc307e28f713ec70d2247a (diff) | |
download | qtbase-b4cc29434769b1d6c08ab2fc76cdcc2dac5dede9.tar.gz |
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>
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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); |