From 003282c6f5ed89de4bc5a2ddeffdea59286b455f Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 16 Jun 2020 17:05:56 +0200 Subject: [PATCH] QmlDesigner: Fix crash on puppet Change-Id: I233d3dab5a509bfd7c9a30c7dcc15dcf8751f456 Reviewed-by: Tim Jenssen --- .../qml2puppet/instances/objectnodeinstance.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 840b71c6711..5991e2b28e9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -779,7 +779,9 @@ QObject *ObjectNodeInstance::createComponent(const QUrl &componentUrl, QQmlConte return QmlPrivateGate::createComponent(componentUrl, context); } -QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, const QByteArray &importCode, QQmlContext *context) +QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, + const QByteArray &importCode, + QQmlContext *context) { QmlPrivateGate::ComponentCompleteDisabler disableComponentComplete; Q_UNUSED(disableComponentComplete) @@ -790,9 +792,11 @@ QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, data.prepend(importCode); component.setData(data, context->baseUrl().resolved(QUrl("createCustomParserObject.qml"))); QObject *object = component.beginCreate(context); - QmlPrivateGate::tweakObjects(object); - component.completeCreate(); - QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); + if (object) { + QmlPrivateGate::tweakObjects(object); + component.completeCreate(); + QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); + } if (component.isError()) { qWarning() << "Error in:" << Q_FUNC_INFO << component.url().toString();