Fix decimal point bug in Context2D color parsing
authorKent Hansen <kent.hansen@nokia.com>
Mon, 24 Oct 2011 13:04:03 +0000 (15:04 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 24 Oct 2011 13:28:30 +0000 (15:28 +0200)
strtod() uses the locale's decimal point, which for
me is ','. But we want to always use '.' when parsing
color values for Context2D. qstrtod() does that.

This fixes two test failures in qquickcanvasitem.

Change-Id: I2ea58ad328f26903c57c7c80ed95fd24599805f4
Reviewed-by: Charles Yin <charles.yin@nokia.com>
src/declarative/items/context2d/qquickcontext2d.cpp

index 0c0865b..ade890d 100644 (file)
@@ -95,6 +95,9 @@ QT_BEGIN_NAMESPACE
     the canvas.
     \image qml-item-canvas-context.gif
 */
+
+Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
+
 static const double Q_PI   = 3.14159265358979323846;   // pi
 
 #define DEGREES(t) ((t) * 180.0 / Q_PI)
@@ -164,7 +167,8 @@ QColor qt_color_from_string(v8::Local<v8::Value> name)
         if (hasAlpha) {
             if (*p++!= ',') return QColor();
             while (isspace(*p)) p++;
-            alpha = qRound(strtod(p, &p) * 255);
+            bool ok = false;
+            alpha = qRound(qstrtod(p, const_cast<const char **>(&p), &ok) * 255);
         }
 
         if (*p != ')') return QColor();