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:
Fabian Kosmale 2019-12-03 11:13:42 +01:00
parent 5a6fb46488
commit 3359b29c99
2 changed files with 2 additions and 1 deletions

View File

@ -688,7 +688,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL
return QValidator::Invalid;
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())
return QValidator::Invalid;
if (!ok)

View File

@ -73,6 +73,7 @@ void tst_QDoubleValidator::validateThouSep_data()
QTest::newRow("1.000,1de_reject") << "de" << QString("1.000,1") << true << INV;
QTest::newRow(",C") << "C" << QString(",") << false << INV;
QTest::newRow(",de") << "de" << QString(",") << false << ITM;
QTest::newRow("1,23") << "en_AU" << QString("1,00") << false << ITM;
}
void tst_QDoubleValidator::validateThouSep()