summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-12-09 09:59:10 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-12-09 10:04:05 (GMT)
commitb81b8e43ad57183ed66086ec90cabef5906ab9a2 (patch)
tree65615a52ebcf53b683f66be44c0a04bf44d04180 /src/corelib/tools/qlocale.cpp
parent258bc1c288ec9be90a2a101b81f0a3c58d193bca (diff)
downloadQt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.zip
Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.gz
Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.bz2
Fix the int validator not handling the locale
Task-number: QTBUG-3179 Reviewed-by: ogoffart
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r--src/corelib/tools/qlocale.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 4a66b92..c2280c6 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -4293,6 +4293,7 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
const bool scientific = numMode == DoubleScientificMode;
bool lastWasE = false;
+ bool lastWasDigit = false;
int eCnt = 0;
int decPointCnt = 0;
bool dec = false;
@@ -4307,6 +4308,7 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
if (dec && decDigits != -1 && decDigits < ++decDigitCnt)
return false;
}
+ lastWasDigit = true;
} else {
switch (c) {
case '.':
@@ -4344,7 +4346,10 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
break;
case ',':
- return false;
+ //it can only be placed after a digit which is before the decimal point
+ if (!lastWasDigit || decPointCnt > 0)
+ return false;
+ break;
case 'e':
if (scientific) {
@@ -4362,10 +4367,12 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
// If it's not a valid digit, it shall be Invalid.
return false;
}
+ lastWasDigit = false;
}
lastWasE = c == 'e';
- buff->append(c);
+ if (c != ',')
+ buff->append(c);
}
return true;