QLineEdit: check a int->QChar conversion, and make it explicit
QStyle::styleHint returns int, and that int was simply used to build a QChar representing the "password mask" character. Enforce that it actually fits and then do an explicit cast. (In general, of course, this is an API flaw; styleHint should somehow return a QString for this use case). Change-Id: Ifb6181b229b91cc84859cb9b9d57e21d6748c31a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
aa6ad15424
commit
c9b8c2cddb
@ -1679,7 +1679,9 @@ void tst_QLineEdit::displayText_data()
|
|||||||
m << bool(use_setText);
|
m << bool(use_setText);
|
||||||
s = key_mode_str + "Password";
|
s = key_mode_str + "Password";
|
||||||
m = QLineEdit::Password;
|
m = QLineEdit::Password;
|
||||||
QChar passChar = qApp->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, 0, m_testWidget);
|
const int passwordCharacter = qApp->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, 0, m_testWidget);
|
||||||
|
QVERIFY(passwordCharacter <= 0xFFFF);
|
||||||
|
const QChar passChar(passwordCharacter);
|
||||||
QString input;
|
QString input;
|
||||||
QString pass;
|
QString pass;
|
||||||
input = "Hello World";
|
input = "Hello World";
|
||||||
@ -1725,7 +1727,9 @@ void tst_QLineEdit::passwordEchoOnEdit()
|
|||||||
|
|
||||||
QStyleOptionFrame opt;
|
QStyleOptionFrame opt;
|
||||||
QLineEdit *testWidget = ensureTestWidget();
|
QLineEdit *testWidget = ensureTestWidget();
|
||||||
QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
const int passwordCharacter = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
||||||
|
QVERIFY(passwordCharacter <= 0xFFFF);
|
||||||
|
const QChar fillChar(passwordCharacter);
|
||||||
|
|
||||||
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
||||||
testWidget->setFocus();
|
testWidget->setFocus();
|
||||||
@ -1772,7 +1776,9 @@ void tst_QLineEdit::passwordEchoDelay()
|
|||||||
QSKIP("Platform not defining echo delay and overriding only possible in internal build");
|
QSKIP("Platform not defining echo delay and overriding only possible in internal build");
|
||||||
|
|
||||||
QStyleOptionFrame opt;
|
QStyleOptionFrame opt;
|
||||||
QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
const int passwordCharacter = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
||||||
|
QVERIFY(passwordCharacter <= 0xFFFF);
|
||||||
|
const QChar fillChar(passwordCharacter);
|
||||||
|
|
||||||
testWidget->setEchoMode(QLineEdit::Password);
|
testWidget->setEchoMode(QLineEdit::Password);
|
||||||
testWidget->setFocus();
|
testWidget->setFocus();
|
||||||
@ -3917,7 +3923,9 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
|
|||||||
|
|
||||||
QStyleOptionFrame opt;
|
QStyleOptionFrame opt;
|
||||||
QLineEdit *testWidget = ensureTestWidget();
|
QLineEdit *testWidget = ensureTestWidget();
|
||||||
QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
const int passwordCharacter = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
||||||
|
QVERIFY(passwordCharacter <= 0xFFFF);
|
||||||
|
const QChar fillChar(passwordCharacter);
|
||||||
|
|
||||||
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
||||||
testWidget->setFocus();
|
testWidget->setFocus();
|
||||||
|
Loading…
Reference in New Issue
Block a user