diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-05-09 14:04:08 +1000 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-01 06:55:27 +0200 |
commit | 3c7793acc0a5688e17ce2860c70fed7eae8690bb (patch) | |
tree | 960156d68c25cfe2a621b3bc965106ce8df9134b /src | |
parent | 15871d606a0a85cfcd2b68b95c0891165f61e402 (diff) |
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
(cherry picked from commit 6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298)
Reviewed-on: http://codereview.qt.nokia.com/290
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src')
-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 ee7d7fb126..bf36033c08 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); |