diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-24 15:47:15 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-25 07:08:50 +0000 |
commit | 18db0b49c61790e5a984ca93b9023a547fca8022 (patch) | |
tree | 842712066baaf09cfbfb304c88fa13e01c7b44d3 /src/gui/text/qtextdocumentlayout.cpp | |
parent | 73031ebb998b687b0997bae7beeef37571c2b360 (diff) | |
download | qtbase-18db0b49c61790e5a984ca93b9023a547fca8022.tar.gz |
Don't crash on <br> following a <table>
A <br> has a new-line but no text, so be able to handle no lines.
Task-number: QTBUG-60853
Change-Id: I3d4dbd529114bbe8afe760c3622b52446202ec7c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 9877a23fa6..2957b8d5c0 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2494,7 +2494,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout QTextTableData *td = static_cast<QTextTableData *>(data(lastIt.currentFrame())); QTextLayout *layout = block.layout(); - QFixed height = QFixed::fromReal(layout->lineAt(0).height()); + QFixed height = layout->lineCount() > 0 ? QFixed::fromReal(layout->lineAt(0).height()) : QFixed(); if (layoutStruct->pageBottom == origPageBottom) { layoutStruct->y -= height; @@ -2506,10 +2506,12 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr); } - QPointF linePos((td->position.x + td->size.width).toReal(), - (td->position.y + td->size.height - height).toReal()); + if (layout->lineCount() > 0) { + QPointF linePos((td->position.x + td->size.width).toReal(), + (td->position.y + td->size.height - height).toReal()); - layout->lineAt(0).setPosition(linePos - layout->position()); + layout->lineAt(0).setPosition(linePos - layout->position()); + } } if (blockFormat.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter) |