Set isRoot correctly for value types
authorAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 5 Oct 2011 07:32:05 +0000 (17:32 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 5 Oct 2011 08:41:32 +0000 (10:41 +0200)
Change-Id: I1ddbe5a76fd804df51a3feaf1c0a9004a67abf9f
Reviewed-on: http://codereview.qt-project.org/6023
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>

src/declarative/qml/qdeclarativecompiler.cpp

index 69df595..dc992b5 100644 (file)
@@ -3118,13 +3118,15 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         store.value = ref.compiledIndex;
         store.context = ref.bindingContext.stack;
         store.owner = ref.bindingContext.owner;
-        if (valueTypeProperty) 
+        if (valueTypeProperty) {
             store.property = (valueTypeProperty->index & 0xFFFF) |
                              ((valueTypeProperty->type & 0xFF)) << 16 |
                              ((prop->index & 0xFF) << 24);
-        else 
+            store.isRoot = (compileState->root == valueTypeProperty->parent);
+        } else {
             store.property = prop->index;
-        store.isRoot = (compileState->root == obj);
+            store.isRoot = (compileState->root == obj);
+        }
         store.line = binding->location.start.line;
         output->addInstruction(store);
     } else if (ref.dataType == BindingReference::V8) {
@@ -3132,7 +3134,11 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         store.value = ref.compiledIndex;
         store.context = ref.bindingContext.stack;
         store.owner = ref.bindingContext.owner;
-        store.isRoot = (compileState->root == obj);
+        if (valueTypeProperty) {
+            store.isRoot = (compileState->root == valueTypeProperty->parent);
+        } else {
+            store.isRoot = (compileState->root == obj);
+        }
         store.line = binding->location.start.line;
 
         Q_ASSERT(ref.bindingContext.owner == 0 ||
@@ -3149,9 +3155,14 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         store.assignBinding.value = output->indexForString(ref.rewrittenExpression);
         store.assignBinding.context = ref.bindingContext.stack;
         store.assignBinding.owner = ref.bindingContext.owner;
-        store.assignBinding.isRoot = (compileState->root == obj);
         store.assignBinding.line = binding->location.start.line;
 
+        if (valueTypeProperty) {
+            store.assignBinding.isRoot = (compileState->root == valueTypeProperty->parent);
+        } else {
+            store.assignBinding.isRoot = (compileState->root == obj);
+        }
+
         Q_ASSERT(ref.bindingContext.owner == 0 ||
                  (ref.bindingContext.owner != 0 && valueTypeProperty));
         if (ref.bindingContext.owner) {