diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2019-01-25 15:40:56 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2019-01-25 14:56:08 +0000 |
commit | 80a92d55d3afcc455882d81185f9de6f35687a00 (patch) | |
tree | fed3be0c67910ab80a904b59bfe80994e838c94b | |
parent | 05cc1a77e58405427f85504ac9aaf8dca771ba3e (diff) | |
download | qt-creator-80a92d55d3afcc455882d81185f9de6f35687a00.tar.gz |
QmlDesigner: Fix gradients in Qt 5.12.1
In Qt 5.12.1 gradient is a QJSValue.
See commit 1771d298f33543a3fe47decfe0fff10609b01ab1
This patch adds QJSValue support.
Change-Id: I1c37b82bf033c38646564d5453e297258dd4b056
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 7af165a9c6..3720bdc90a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -44,6 +44,7 @@ #include <QQmlParserStatus> #include <QTextDocument> #include <QLibraryInfo> +#include <QJSValue> static bool isSimpleExpression(const QString &expression) { @@ -264,11 +265,17 @@ static bool isList(const QQmlProperty &property) return property.propertyTypeCategory() == QQmlProperty::List; } +static bool isQJSValue(const QQmlProperty &property) +{ + return !strcmp(property.propertyTypeName(), "QJSValue"); +} + static bool isObject(const QQmlProperty &property) { - return (property.propertyTypeCategory() == QQmlProperty::Object) || - //QVariant can also store QObjects. Lets trust our model. - (QLatin1String(property.propertyTypeName()) == QLatin1String("QVariant")); + /* QVariant and QJSValue can also store QObjects. Lets trust our model. */ + return (property.propertyTypeCategory() == QQmlProperty::Object + || !strcmp(property.propertyTypeName(), "QVariant") + || isQJSValue(property)); } static QVariant objectToVariant(QObject *object) @@ -337,7 +344,10 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c list.append(object); } else if (isObject(property)) { - property.write(objectToVariant(object)); + if (isQJSValue(property)) /* In this case we have to explcitly generate and convert a QJSValue */ + property.write(QVariant::fromValue(engine()->newQObject(object))); + else + property.write(objectToVariant(object)); if (QQuickItem *item = qobject_cast<QQuickItem *>(object)) if (QQuickItem *newParentItem = qobject_cast<QQuickItem *>(newParent)) |