Fix delayed password masking mid-string.
Unmask the last character typed, not the last character in the string. Change-Id: I9c70d2347bf878c18ab0a7f4ea76f755ca19a85c Task-number: QTBUG-17003 Reviewed-by: Alan Alpert (cherry picked from commit b98e9e69dd8ba33d5f01b9518d95b63b86c4b443) Reviewed-on: http://codereview.qt.nokia.com/4165 Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
This commit is contained in:
parent
8febd56940
commit
06e2ce51d1
@ -60,7 +60,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef QT_GUI_PASSWORD_ECHO_DELAY
|
||||
static int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY;
|
||||
static const int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@ -115,8 +115,8 @@ void QLineControl::updateDisplayText(bool forceUpdate)
|
||||
if (m_echoMode == QLineEdit::Password) {
|
||||
str.fill(m_passwordCharacter);
|
||||
#ifdef QT_GUI_PASSWORD_ECHO_DELAY
|
||||
if (m_passwordEchoTimer != 0 && !str.isEmpty()) {
|
||||
int cursor = m_text.length() - 1;
|
||||
if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) {
|
||||
int cursor = m_cursor - 1;
|
||||
QChar uc = m_text.at(cursor);
|
||||
str[cursor] = uc;
|
||||
if (cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) {
|
||||
|
@ -1728,6 +1728,13 @@ void tst_QLineEdit::passwordEchoDelay()
|
||||
QApplication::sendEvent(testWidget, &ev);
|
||||
QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
|
||||
|
||||
testWidget->setCursorPosition(3);
|
||||
QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
|
||||
QTest::keyPress(testWidget, 'a');
|
||||
QCOMPARE(testWidget->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
|
||||
QTest::keyPress(testWidget, Qt::Key_Backspace);
|
||||
QCOMPARE(testWidget->displayText(), QString(8, fillChar));
|
||||
|
||||
// restore clean state
|
||||
testWidget->setEchoMode(QLineEdit::Normal);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user