diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-12-20 07:07:34 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-12-20 07:07:34 (GMT) |
commit | 197ec350e4014330851a013501c6dde3068ac26f (patch) | |
tree | f6289720da5b8e280a7849c5dd52b5a3a1629a10 /src | |
parent | 95e64de1827f9b2bae829d40756f7142c56c460f (diff) | |
download | Qt-197ec350e4014330851a013501c6dde3068ac26f.zip Qt-197ec350e4014330851a013501c6dde3068ac26f.tar.gz Qt-197ec350e4014330851a013501c6dde3068ac26f.tar.bz2 |
Setting TextInput.cursorPosition outside bounds crashed.
Check bounds in TextInput and TextEdit.
Task-number: QTBUG-16188
Reviewed-by: Bea Lam
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index e05f4e4..4e16d24 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -643,6 +643,8 @@ int QDeclarativeTextEdit::cursorPosition() const void QDeclarativeTextEdit::setCursorPosition(int pos) { Q_D(QDeclarativeTextEdit); + if (pos < 0 || pos > d->text.length()) + return; QTextCursor cursor = d->control->textCursor(); if (cursor.position() == pos) return; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index df103de..521e4ab 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -437,6 +437,8 @@ int QDeclarativeTextInput::cursorPosition() const void QDeclarativeTextInput::setCursorPosition(int cp) { Q_D(QDeclarativeTextInput); + if (cp < 0 || cp > d->control->text().length()) + return; d->control->moveCursor(cp); } |