summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-12-03 11:13:42 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2019-12-05 11:30:24 +0100
commit3359b29c99581f52acf033489ad35884a01ccac8 (patch)
tree5b607ee0309f2de830fcf562a906dd762f29f249
parent5a6fb46488ebc26b79b9d37a7f91969e0d852b4f (diff)
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>
-rw-r--r--src/gui/util/qvalidator.cpp2
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 2237b016e9..54cbb28ffa 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -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)
diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
index 012a7e2ce3..366f3b6fdf 100644
--- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
+++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -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()