diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2012-04-02 12:32:05 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-03 09:12:33 +0200 |
commit | ebfbabf1f3c2e65acecdb06de3b3a47a933e38f9 (patch) | |
tree | 6812afc7d5c2ff2cb5f26a9f659a47ca56724b36 /src/gui | |
parent | 8cd69eb1ffd37194e3d736a3bb5ce8511b8b8854 (diff) |
Fix a crash in cursorToX() when new block is added
When an empty new block is being added, the layoutData->memory data
will be 0, thus QTextEngine::attributes() will return 0. We should
only access the attributes pointer when some text actually exist.
Task-number: QTBUG-24718
Change-Id: I9ce9f7b57bccf24099a02832ce30fb6cebfaad33
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index ee658d9e41..16f7150270 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2508,6 +2508,10 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const int pos = *cursorPos; int itm; const HB_CharAttributes *attributes = eng->attributes(); + if (!attributes) { + *cursorPos = 0; + return x.toReal(); + } while (pos < line.from + line.length && !attributes[pos].charStop) pos++; if (pos == line.from + (int)line.length) { |