diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-05-09 04:04:08 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-05-12 02:50:26 (GMT) |
commit | 6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298 (patch) | |
tree | 534fa85d595a6d445ea00dfee91a9ab4e04bb0da | |
parent | 4fbcb6a531bf424a8dbbbd0ca2947d9e15118885 (diff) | |
download | Qt-6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298.zip Qt-6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298.tar.gz Qt-6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298.tar.bz2 |
Don't crash on an invalid replacementStart from an input method.
Ensure the cursor position does not exceed the bounds of the
current text.
Change-Id: If38f7729372562324d11eadd1a976c0c6da91863
Task-number: QTBUG-19054
Reviewed-by: Martin Jones
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 202ea7a..8d4a90e 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -435,6 +435,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); + if (m_cursor < 0) + m_cursor = 0; // insert commit string if (event->replacementLength()) { @@ -447,7 +449,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) cursorPositionChanged = true; } - m_cursor = qMin(c, m_text.length()); + m_cursor = qBound(0, c, m_text.length()); for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); |