Fix crash in var property setter
authorChris Adams <christopher.adams@nokia.com>
Fri, 23 Dec 2011 03:01:25 +0000 (13:01 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Dec 2011 03:20:18 +0000 (04:20 +0100)
Previously, the function didn't terminate after calling the setter
recursively, as it should have.  This patch ensures that the setter
is called correctly and then returns, and adds a unit test to ensure
that no regression occurs.

Task-number: QTBUG-23330
Change-Id: If512fca174e5224c2c53caad11f77782e6cead9f
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
src/declarative/qml/qdeclarativevmemetaobject.cpp
tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp

index a37be92..e5e8641 100644 (file)
@@ -992,6 +992,7 @@ void QDeclarativeVMEMetaObject::setVMEProperty(int index, v8::Handle<v8::Value>
     if (index < propOffset) {
         Q_ASSERT(parent);
         static_cast<QDeclarativeVMEMetaObject *>(parent)->setVMEProperty(index, v);
+        return;
     }
     return writeVarProperty(index - propOffset, v);
 }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml b/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml
new file mode 100644 (file)
index 0000000..5f28833
--- /dev/null
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Item {
+    property var random: null
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml
new file mode 100644 (file)
index 0000000..ac7f2be
--- /dev/null
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+PropertyVarBaseItem {
+    property bool test: false
+    Component.onCompleted: {
+        test = true;
+    }
+}
index 8a028ae..0e3cfd8 100644 (file)
@@ -3701,6 +3701,7 @@ void tst_qdeclarativeecmascript::propertyVar_data()
     QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
     QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
     QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
+    QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
 }
 
 void tst_qdeclarativeecmascript::propertyVar()