From: Lars Knoll Date: Mon, 10 Dec 2012 23:41:35 +0000 (+0100) Subject: Use QString::toDouble to convert to numbers X-Git-Tag: upstream/5.2.1~669^2~659^2~725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b268bd9dbaf4e33a73a175cfddb517c51c0a2ed6;p=platform%2Fupstream%2Fqtdeclarative.git Use QString::toDouble to convert to numbers QString::toDouble() is always using the C locale in Qt 5, strtod_l seems to have some stability issues for me, and creating a locale on the stack doesn't sound very performant. Change-Id: I35705a125b0c5913a5390ed1429c4e7490300f92 Reviewed-by: Erik Verbruggen --- diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp index 62e7be4..1e664d2 100644 --- a/qmljs_runtime.cpp +++ b/qmljs_runtime.cpp @@ -44,6 +44,7 @@ #include "qmljs_objects.h" #include "qv4ir_p.h" #include "qv4ecmaobjects_p.h" +#include "private/qlocale_tools_p.h" #include #include @@ -52,7 +53,6 @@ #include #include #include -#include namespace QQmlJS { namespace VM { @@ -436,9 +436,17 @@ double __qmljs_string_to_number(ExecutionContext *, String *string) const QString s = string->toQString(); if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X"))) return s.toLong(0, 16); - locale_t c_locale = newlocale(LC_ALL_MASK, NULL, NULL); - double d = ::strtod_l(s.toUtf8().constData(), 0, c_locale); - freelocale(c_locale); + bool ok; + QByteArray ba = s.toLatin1(); + const char *begin = ba.constData(); + const char *end = 0; + double d = qstrtod(begin, &end, &ok); + if (end - begin != ba.size() - 1) { + if (ba == "Infinity") + d = INFINITY; + else + d = nan(""); + } return d; } diff --git a/v4.pro b/v4.pro index 3aecdab..1f1604b 100644 --- a/v4.pro +++ b/v4.pro @@ -1,4 +1,4 @@ -QT = core qmldevtools-private +QT = core-private qmldevtools-private CONFIG -= app_bundle CONFIG += console