From 0ce1d0c0e41dab04b2267fed1fe20b70884765a4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 22 Nov 2011 13:43:10 +0000 Subject: [PATCH] Don't disconnect mid binding evaluation Task-number: QTBUG-22816 Change-Id: I7a958203945a051322228b6fade9e1d49d5f4c4a Reviewed-by: Roberto Raggi --- src/declarative/qml/v4/qv4bindings.cpp | 2 ++ tests/auto/declarative/v4/data/qtbug_22816.qml | 18 ++++++++++++++++++ tests/auto/declarative/v4/tst_v4.cpp | 12 ++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/auto/declarative/v4/data/qtbug_22816.qml diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp index b398ac5..1f93427 100644 --- a/src/declarative/qml/v4/qv4bindings.cpp +++ b/src/declarative/qml/v4/qv4bindings.cpp @@ -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 index 0000000..bfa8d49 --- /dev/null +++ b/tests/auto/declarative/v4/data/qtbug_22816.qml @@ -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; + } +} + diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 20d739f..69fa4bb 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -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" -- 2.7.4