From 6ec2174791ad254f82ce89618a3642eb3e0689c7 Mon Sep 17 00:00:00 2001
From: Christian Kamm <christian.d.kamm@nokia.com>
Date: Fri, 13 Aug 2010 13:26:44 +0200
Subject: [PATCH] QmlJS: Use QmlJS::toQColor to convert a string to a QColor.

The QColor constructor prints a warning if the string it gets passed
isn't a known color name. Also, it doesn't know about the alpha value
in strings like "#ff00ff00".

Reviewed-by: Thomas Hartmann
---
 src/libs/qmleditorwidgets/contextpanewidgetrectangle.cpp | 3 ++-
 src/libs/qmljs/qmljspropertyreader.cpp                   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libs/qmleditorwidgets/contextpanewidgetrectangle.cpp b/src/libs/qmleditorwidgets/contextpanewidgetrectangle.cpp
index 193d86903d3..e80df1aabdd 100644
--- a/src/libs/qmleditorwidgets/contextpanewidgetrectangle.cpp
+++ b/src/libs/qmleditorwidgets/contextpanewidgetrectangle.cpp
@@ -31,6 +31,7 @@
 #include "ui_contextpanewidgetrectangle.h"
 #include "contextpanewidget.h"
 #include <qmljs/qmljspropertyreader.h>
+#include <qmljs/qmljscheck.h>
 #include <customcolordialog.h>
 #include <QDebug>
 
@@ -79,7 +80,7 @@ void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyRe
 
     if (propertyReader->hasProperty(QLatin1String("color"))) {
         QString str = propertyReader->readProperty("color").toString();
-        if (QColor(str).alpha() == 0)
+        if (QmlJS::toQColor(str).alpha() == 0)
             m_none = true;
         ui->colorColorButton->setColor(str);
 
diff --git a/src/libs/qmljs/qmljspropertyreader.cpp b/src/libs/qmljs/qmljspropertyreader.cpp
index ac820093811..d8e7946ed06 100644
--- a/src/libs/qmljs/qmljspropertyreader.cpp
+++ b/src/libs/qmljs/qmljspropertyreader.cpp
@@ -30,6 +30,7 @@
 #include "qmljspropertyreader.h"
 #include "qmljsdocument.h"
 #include <qmljs/parser/qmljsast_p.h>
+#include <qmljs/qmljscheck.h>
 
 namespace QmlJS {
 
@@ -265,7 +266,7 @@ QLinearGradient PropertyReader::parseGradient(const QString &propertyName,  bool
                     if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) {
                         PropertyReader localParser(m_doc, objectDefinition->initializer);
                         if (localParser.hasProperty("color") && localParser.hasProperty("position")) {
-                            QColor color = localParser.readProperty("color").value<QColor>();
+                            QColor color = QmlJS::toQColor(localParser.readProperty("color").toString());
                             qreal position = localParser.readProperty("position").toReal();
                             if (localParser.isBindingOrEnum("color") || localParser.isBindingOrEnum("position"))
                                 *isBound = true;
-- 
GitLab