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();