From: Yuchen Deng Date: Sat, 31 Dec 2011 11:26:45 +0000 (+0800) Subject: Avoiding crash when insert preEditString X-Git-Tag: qt-v5.0.0-alpha1~1980 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0277f14f48539d5f9d443c7d4135a54d4a5e2a62;p=profile%2Fivi%2Fqtbase.git Avoiding crash when insert preEditString We will insert an preEditString by QInputMethodEvent See: Task-number: QTCREATORBUG-5633 Task-number: QTCREATORBUG-6082 Change-Id: I8cfc7ab2543455dfdff8ec3df983d384513453e0 Reviewed-by: Robin Burchell Reviewed-by: Lars Knoll --- diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 10bbff3..6bbf1be 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -495,6 +495,8 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor break; } newPosition = blockIt.position() + line.textStart() + line.textLength(); + if (newPosition >= priv->length()) + newPosition = priv->length() - 1; if (line.lineNumber() < layout->lineCount() - 1) { const QString text = blockIt.text(); // ###### this relies on spaces being the cause for linebreaks.