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>
This commit is contained in:
Miikka Heikkinen
2020-04-02 14:22:59 +03:00
parent da558f3376
commit 09f34a697f

View File

@@ -753,10 +753,14 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC
Q_UNUSED(disableComponentComplete) Q_UNUSED(disableComponentComplete)
QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath)); QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath));
QObject *object = component.beginCreate(context);
QmlPrivateGate::tweakObjects(object); QObject *object = nullptr;
component.completeCreate(); if (!component.isError()) {
object = component.beginCreate(context);
QmlPrivateGate::tweakObjects(object);
component.completeCreate();
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
}
if (component.isError()) { if (component.isError()) {
qDebug() << componentPath; qDebug() << componentPath;
@@ -764,8 +768,6 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC
qWarning() << error; qWarning() << error;
} }
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
return object; return object;
} }