From 174eb7c270d13589954523b6cdf90a9d4ff75624 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 15 Oct 2012 14:48:57 +0200 Subject: [PATCH] QmlDesigner.NodeInstances: Fix crash for instance without object Change-Id: Ia08cdb194e8f67a71cdbddf162cc7f17daa517f8 Reviewed-by: Thomas Hartmann --- .../qml2puppet/instances/servernodeinstance.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 60be2cb677..9a6572ccfa 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -213,8 +213,17 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe object = Internal::ObjectNodeInstance::createPrimitive(instanceContainer.type(), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context()); } - if ((object == 0) && (instanceContainer.metaType() == InstanceContainer::ItemMetaType)) //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead. - object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 2, 0, nodeInstanceServer->context()); + if (object == 0) { + if (instanceContainer.metaType() == InstanceContainer::ItemMetaType) { //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead. + object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 2, 0, nodeInstanceServer->context()); + + if (object == 0) + object = new QQuickItem; + } else { + object = new QObject; + } + } + QQmlEnginePrivate::get(nodeInstanceServer->engine())->cache(object->metaObject()); -- GitLab