From 29c97b458d40d6bd86ee9bf8c4c8bc30d99add53 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 12 May 2011 16:48:36 +0200 Subject: [PATCH] QmlDesigner.textToModelMerger: avoid possible crash The setup should be after changing the type. Also we have to check for the case where the ModelNode is the root node. --- .../designercore/model/texttomodelmerger.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index dced7561f31..b458a584b3d 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -767,13 +767,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, propertyIsComponentType(modelNode.parentProperty()) ? QLatin1String("QtQuick.Component") : typeName; - if (isComponentType(typeNameFixedForImplicitComponents)) - setupComponent(modelNode); - - if (isCustomParserType(typeName)) - setupCustomParserNode(modelNode); - - if (modelNode.parentProperty().isValid() && modelNode.type() != typeNameFixedForImplicitComponents //If there is no valid parentProperty + if ((modelNode.parentProperty().isValid() || modelNode.isRootNode()) && modelNode.type() != typeNameFixedForImplicitComponents //If there is no valid parentProperty //the node has just been created. The type is correct then. /*|| modelNode.majorVersion() != domObject.objectTypeMajorVersion() || modelNode.minorVersion() != domObject.objectTypeMinorVersion()*/) { @@ -785,6 +779,12 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, return; // the difference handler will create a new node, so we're done. } + if (isComponentType(typeNameFixedForImplicitComponents)) + setupComponent(modelNode); + + if (isCustomParserType(typeName)) + setupCustomParserNode(modelNode); + context->enterScope(astNode); QSet modelPropertyNames = QSet::fromList(modelNode.propertyNames());