QmlDesigner: Fix crash for QQuickStyleItem

QQuickStyleItem crashes if componentComplete() is called.

Change-Id: I1df1b50f6ba95c0eda1ff8e18de85276a6de04f5
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2021-07-16 15:15:02 +02:00
parent bbf2dab8cb
commit c59bddd4df

View File

@@ -167,6 +167,26 @@ void registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine)
QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(object, engine); QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(object, engine);
} }
static bool isQuickStyleItemMetaObject(const QMetaObject *metaObject)
{
if (metaObject) {
if (metaObject->className() == QByteArrayLiteral("QQuickStyleItem"))
return true;
return isQuickStyleItemMetaObject(metaObject->superClass());
}
return false;
}
static bool isQuickStyleItem(QObject *object)
{
if (object)
return isQuickStyleItemMetaObject(object->metaObject());
return false;
}
// This is used in share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp // This is used in share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context) QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
{ {
@@ -357,6 +377,8 @@ void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInsta
doComponentCompleteRecursive(child, nodeInstanceServer); doComponentCompleteRecursive(child, nodeInstanceServer);
} }
if (!isQuickStyleItem(item)) {
qDebug() << Q_FUNC_INFO << item;
if (item) { if (item) {
static_cast<QQmlParserStatus *>(item)->componentComplete(); static_cast<QQmlParserStatus *>(item)->componentComplete();
} else { } else {
@@ -366,6 +388,7 @@ void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInsta
} }
} }
} }
}
void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName) void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName)