Don't disconnect mid binding evaluation
authorAaron Kennedy <aaron.kennedy@nokia.com>
Tue, 22 Nov 2011 13:43:10 +0000 (13:43 +0000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 22 Nov 2011 13:45:14 +0000 (14:45 +0100)
Task-number: QTBUG-22816
Change-Id: I7a958203945a051322228b6fade9e1d49d5f4c4a
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
src/declarative/qml/v4/qv4bindings.cpp
tests/auto/declarative/v4/data/qtbug_22816.qml [new file with mode: 0644]
tests/auto/declarative/v4/tst_v4.cpp

index b398ac5..1f93427 100644 (file)
@@ -342,6 +342,8 @@ void QV4Bindings::subscribeId(QDeclarativeContextData *p, int idIndex, int subIn
 void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex)
 {
     Subscription *sub = (subscriptions + subIndex);
+    if (sub->isConnected(o, notifyIndex))
+        return;
     sub->bindings = this;
     sub->method = subIndex; 
     if (o)
diff --git a/tests/auto/declarative/v4/data/qtbug_22816.qml b/tests/auto/declarative/v4/data/qtbug_22816.qml
new file mode 100644 (file)
index 0000000..bfa8d49
--- /dev/null
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+Item {
+    QtObject {
+        id: object
+        property bool prop1: true
+        function myfunction() { return true; }
+        property bool prop2: object.prop1 && myfunction();
+    }
+
+    property bool test1: object.prop1 && object.prop2
+    property bool test2: object.prop1
+
+    Component.onCompleted: {
+        object.prop1 = false;
+    }
+}
+
index 20d739f..69fa4bb 100644 (file)
@@ -78,6 +78,7 @@ private slots:
     void nestedObjectAccess();
     void subscriptionsInConditionalExpressions();
     void qtbug_21883();
+    void qtbug_22816();
 
 private:
     QDeclarativeEngine engine;
@@ -253,6 +254,17 @@ void tst_v4::qtbug_21883()
     delete o;
 }
 
+void tst_v4::qtbug_22816()
+{
+    QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22816.qml"));
+
+    QObject *o = component.create();
+    QVERIFY(o != 0);
+    QCOMPARE(o->property("test1").toBool(), false);
+    QCOMPARE(o->property("test2").toBool(), false);
+    delete o;
+}
+
 QTEST_MAIN(tst_v4)
 
 #include "tst_v4.moc"