QDoubleValidator: Fix thousand separator handling
QDoubleValidator would accept "1,23" as valid in a locale which has ',' as a thousand separator. However, it should have been Intermediate instead, as there is still one digit missing. Fixes: QTBUG-75110 Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
5a6fb46488
commit
3359b29c99
@ -688,7 +688,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL
|
|||||||
return QValidator::Invalid;
|
return QValidator::Invalid;
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
double i = buff.toDouble(&ok); // returns 0.0 if !ok
|
double i = locale.toDouble(input, &ok); // returns 0.0 if !ok
|
||||||
if (i == qt_qnan())
|
if (i == qt_qnan())
|
||||||
return QValidator::Invalid;
|
return QValidator::Invalid;
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
@ -73,6 +73,7 @@ void tst_QDoubleValidator::validateThouSep_data()
|
|||||||
QTest::newRow("1.000,1de_reject") << "de" << QString("1.000,1") << true << INV;
|
QTest::newRow("1.000,1de_reject") << "de" << QString("1.000,1") << true << INV;
|
||||||
QTest::newRow(",C") << "C" << QString(",") << false << INV;
|
QTest::newRow(",C") << "C" << QString(",") << false << INV;
|
||||||
QTest::newRow(",de") << "de" << QString(",") << false << ITM;
|
QTest::newRow(",de") << "de" << QString(",") << false << ITM;
|
||||||
|
QTest::newRow("1,23") << "en_AU" << QString("1,00") << false << ITM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QDoubleValidator::validateThouSep()
|
void tst_QDoubleValidator::validateThouSep()
|
||||||
|
Loading…
Reference in New Issue
Block a user