From e58e9f59c78751ebc6d3ef417b7c79c30b3282c3 Mon Sep 17 00:00:00 2001
From: Erik Verbruggen <erik.verbruggen@nokia.com>
Date: Mon, 11 Jan 2010 14:34:58 +0100
Subject: [PATCH] Changed ID setting to be done before type change when reading
 from a file.

---
 .../core/model/texttomodelmerger.cpp          | 28 ++++++++-----------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
index 3b844749e2d..7646865cb8d 100644
--- a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp
@@ -122,14 +122,11 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, const QmlDomObject &domOb
 {
     m_rewriterView->positionStorage()->setNodeOffset(modelNode, domObject.position());
 
-    if (modelNode.type() != domObject.objectType()
-            || modelNode.majorVersion() != domObject.objectTypeMajorVersion()
-            || modelNode.minorVersion() != domObject.objectTypeMinorVersion()) {
-        differenceHandler.typeDiffers(modelNode, domObject);
-    }
-
     {
-        const QString domObjectId = domObject.objectId();
+        QString domObjectId = domObject.objectId();
+        const QmlDomProperty domIdProperty = domObject.property("id");
+        if (domObjectId.isEmpty() && domIdProperty.value().isLiteral())
+            domObjectId = domIdProperty.value().toLiteral().literal();
 
         if (domObjectId.isEmpty()) {
             if (!modelNode.id().isEmpty())
@@ -140,6 +137,12 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, const QmlDomObject &domOb
         }
     }
 
+    if (modelNode.type() != domObject.objectType()
+            || modelNode.majorVersion() != domObject.objectTypeMajorVersion()
+            || modelNode.minorVersion() != domObject.objectTypeMinorVersion()) {
+        differenceHandler.typeDiffers(modelNode, domObject);
+    }
+
     QSet<QString> modelPropertyNames = QSet<QString>::fromList(modelNode.propertyNames());
 
     foreach (const QmlDomProperty &domProperty, domObject.properties()) {
@@ -149,15 +152,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, const QmlDomObject &domOb
             continue;
 
         if (domPropertyName == QLatin1String("id")) {
-            const QmlDomValue domValue = domProperty.value();
-            if (domValue.isLiteral()) {
-                const QString domId = domValue.toLiteral().literal();
-
-                if (modelNode.id() != domId)
-                    differenceHandler.idsDiffer(modelNode, domId);
-            } else {
-                qWarning() << "id property found which is not a literal";
-            }
+            // already done before
+            continue;
         } else if (domPropertyName.isEmpty()) {
             qWarning() << "QML DOM returned an empty property name";
             continue;
-- 
GitLab