From 443ba99b1ef825e198fe1999c34ee44547135797 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 18 Feb 2016 13:18:33 +0200 Subject: Prevent cutting in non-Normal echoMode of TextInput Cutting the text in Password mode led to the text being deleted. Cut and copy operations should not be allowed when echoMode is set to a mode other than Normal. Task-number: QTBUG-51231 Change-Id: If75cdaedac7478ecc1a5126ad4a5ecbf32acd1ab Reviewed-by: Robin Burchell --- src/quick/items/qquicktextinput.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index ba7142856b..ffc94dfd46 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1886,11 +1886,15 @@ bool QQuickTextInput::isRightToLeft(int start, int end) \qmlmethod QtQuick::TextInput::cut() Moves the currently selected text to the system clipboard. + + \note If the echo mode is set to a mode other than Normal then cut + will not work. This is to prevent using cut as a method of bypassing + password features of the line control. */ void QQuickTextInput::cut() { Q_D(QQuickTextInput); - if (!d->m_readOnly) { + if (!d->m_readOnly && d->m_echoMode == QQuickTextInput::Normal) { d->copy(); d->del(); } @@ -1900,6 +1904,10 @@ void QQuickTextInput::cut() \qmlmethod QtQuick::TextInput::copy() Copies the currently selected text to the system clipboard. + + \note If the echo mode is set to a mode other than Normal then copy + will not work. This is to prevent using copy as a method of bypassing + password features of the line control. */ void QQuickTextInput::copy() { @@ -4251,10 +4259,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) } } else if (event == QKeySequence::Cut) { - if (!m_readOnly) { - copy(); - del(); - } + q->cut(); } else if (event == QKeySequence::DeleteEndOfLine) { if (!m_readOnly) -- cgit v1.2.3