aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2020-04-02 14:22:59 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2020-04-02 12:20:35 +0000
commit09f34a697fb6c6ba1a287b842045878d671069da (patch)
treec49bbcdc20ab4d27f98369b7e8737e9a94717369
parentda558f337680e2ba42916a51649876b4cb963fd3 (diff)
QmlDesigner: Fix crash in puppet when component has errors
Check component creation errors earlier to avoid crash. This allows puppet to notify creator about the problem, so invalid components can be properly highlighted in navigator. Change-Id: I059a5be04c4e509a38f6d47daa97e0da36c333ae Fixes: QDS-1887 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
index 1c6601784b..7fabfcf903 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
@@ -753,10 +753,14 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC
Q_UNUSED(disableComponentComplete)
QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath));
- QObject *object = component.beginCreate(context);
- QmlPrivateGate::tweakObjects(object);
- component.completeCreate();
+ QObject *object = nullptr;
+ if (!component.isError()) {
+ object = component.beginCreate(context);
+ QmlPrivateGate::tweakObjects(object);
+ component.completeCreate();
+ QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
+ }
if (component.isError()) {
qDebug() << componentPath;
@@ -764,8 +768,6 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC
qWarning() << error;
}
- QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
-
return object;
}