diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-05-31 12:13:40 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-31 09:56:42 +0200 |
commit | e171d1e8c4b4324374cb57a6d7d181a57fc17dbe (patch) | |
tree | c003e6bc4326aa77262f8aae8edc6ee9373d949e /src/quick/items/qquicktext.cpp | |
parent | 9f9330c524092e63cf5b490d193fd9172938526f (diff) |
Fix assert when calculating the implicit width of truncated lines.
Guard against reading past the end of the final line.
Task-number: QTBUG-31471
Change-Id: I489f742936ee16f12ad9762b7c0891bfa9377e21
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index cf9cb4224f..fbf46f51e4 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -954,7 +954,10 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) // Create the remainder of the unwrapped lines up to maxLineCount to get the // implicit width. - if (line.isValid() && layoutText.at(line.textStart() + line.textLength()) != QChar::LineSeparator) + const int eol = line.isValid() + ? line.textStart() + line.textLength() + : layoutText.length(); + if (eol < layoutText.length() && layoutText.at(eol) != QChar::LineSeparator) line = layout.createLine(); for (; line.isValid() && unwrappedLineCount <= maxLineCount; ++unwrappedLineCount) line = layout.createLine(); |