summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2012-04-02 12:32:05 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-02 14:52:48 +0200
commit19194f02fdaadb800630be240abd044d3668fc10 (patch)
tree7a6e27e05eb4ea8d1baa9d3e64036245c90821a3 /src
parent91c745241fac1149a6c7333effef7aab32dcf41f (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 (cherry picked from commit cac12f4592477d99ef6fffaad40345bf85ef53b5) Change-Id: I203b283dd28653d4b57ba8bfffb259c773f67f19 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextlayout.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index ac91ed00cf..d7f8130c0f 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2587,6 +2587,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) {