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.
This commit is contained in:
Thomas Hartmann
2011-05-12 16:48:36 +02:00
parent 69b9cb8cc7
commit 29c97b458d

View File

@@ -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<QString> modelPropertyNames = QSet<QString>::fromList(modelNode.propertyNames());