From 2ec9b259f63a7305cf221425049cd728adb84bf2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Jan 2010 16:32:58 +1000 Subject: Use QMetaObject::disconnectOne() in QML QTBUG-6781 --- src/declarative/qml/qmlbindingvme.cpp | 4 ++-- src/declarative/qml/qmlexpression.cpp | 18 +++++++++--------- .../declarative/qmlecmascript/tst_qmlecmascript.cpp | 9 ++++++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp index b4b8dc1..29391a6 100644 --- a/src/declarative/qml/qmlbindingvme.cpp +++ b/src/declarative/qml/qmlbindingvme.cpp @@ -383,8 +383,8 @@ inline void subscribe(QObject *o, int notifyIndex, QmlBindingVME::Config::Subscription *s = config->subscriptions + subIndex; if (o != s->source || notifyIndex != s->notifyIndex) { if (s->source) - QMetaObject::disconnect(s->source, s->notifyIndex, - config->target, config->targetSlot + subIndex); + QMetaObject::disconnectOne(s->source, s->notifyIndex, + config->target, config->targetSlot + subIndex); s->source = o; s->notifyIndex = notifyIndex; if (s->source && s->notifyIndex != -1) diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 1587d61..aefa0b1 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -641,9 +641,9 @@ void QmlExpressionPrivate::clearGuards() for (int ii = 0; ii < data->guardListLength; ++ii) { if (data->guardList[ii].data()) { - QMetaObject::disconnect(data->guardList[ii].data(), - data->guardList[ii].notifyIndex, - q, notifyIdx); + QMetaObject::disconnectOne(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); } } @@ -684,9 +684,9 @@ void QmlExpressionPrivate::updateGuards(const QPODVectorguardList[ii].data() && !data->guardList[ii].isDuplicate) { // Cache miss - QMetaObject::disconnect(data->guardList[ii].data(), - data->guardList[ii].notifyIndex, - q, notifyIdx); + QMetaObject::disconnectOne(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); } /* else { // Cache miss, but nothing to do @@ -732,9 +732,9 @@ void QmlExpressionPrivate::updateGuards(const QPODVectorguardListLength; ++ii) { if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) { - QMetaObject::disconnect(data->guardList[ii].data(), - data->guardList[ii].notifyIndex, - q, notifyIdx); + QMetaObject::disconnectOne(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); } } diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index a153296..3aa1aff 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -216,6 +216,13 @@ void tst_qmlecmascript::methods() QCOMPARE(object->property("test2").toInt(), 17); QCOMPARE(object->property("test3").toInt(), 16); } + + { + QmlComponent component(&engine, TEST_FILE("methods.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 9); + } } void tst_qmlecmascript::bindingLoop() @@ -1051,6 +1058,7 @@ void tst_qmlecmascript::compositePropertyType() delete object; } +// QTBUG-6781 void tst_qmlecmascript::bug1() { QmlComponent component(&engine, TEST_FILE("bug.1.qml")); @@ -1065,7 +1073,6 @@ void tst_qmlecmascript::bug1() object->setProperty("b", true); - QEXPECT_FAIL("", "QTBUG-6781", Continue); QCOMPARE(object->property("test").toInt(), 9); delete object; -- cgit v0.12