From: Matthew Vogt Date: Fri, 13 Jul 2012 00:44:39 +0000 (+1000) Subject: Update multiple value type properties despite interceptor X-Git-Tag: upstream/5.2.1~1445 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d166e34bade3b7c82f610f5df209b6418df9e178;p=platform%2Fupstream%2Fqtdeclarative.git Update multiple value type properties despite interceptor When an interceptor is present on a value type, ensure that multiple properties of that value can be updated simultaneously. Task-number: QTBUG-25139 Change-Id: I3042b9883d404aed4b6507e6d2f38a76caee1196 Reviewed-by: Glenn Watson Reviewed-by: Michael Brasser --- diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index c982856..5dcff3e 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -665,13 +665,21 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) valueType->setValue(newValue); QVariant newComponentValue = valueProp.read(valueType); - valueProp.write(valueType, prevComponentValue); - valueType->write(object, id, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + // Don't apply the interceptor if the intercepted value has not changed + bool updated = false; + if (newComponentValue != prevComponentValue) { + valueProp.write(valueType, prevComponentValue); + valueType->write(object, id, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + + vi->write(newComponentValue); + updated = true; + } - vi->write(newComponentValue); + if (!ep) + delete valueType; - if (!ep) delete valueType; - return -1; + if (updated) + return -1; } else { vi->write(QVariant(type, a[0])); return -1; diff --git a/tests/auto/quick/qquickbehaviors/data/multipleChangesToValueType.qml b/tests/auto/quick/qquickbehaviors/data/multipleChangesToValueType.qml new file mode 100644 index 0000000..029a439 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/multipleChangesToValueType.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Text { + id: text + anchors.centerIn: parent + font.pointSize: 24 + Behavior on font.pointSize { NumberAnimation {} } + } + + function updateFontProperties() { + text.font.italic = true + text.font.pointSize = 48 + text.font.weight = Font.Bold + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index bd17bf4..be7ad30 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -80,6 +80,7 @@ private slots: void sameValue(); void delayedRegistration(); void startOnCompleted(); + void multipleChangesToValueType(); }; void tst_qquickbehaviors::simpleBehavior() @@ -468,6 +469,32 @@ void tst_qquickbehaviors::startOnCompleted() delete rect; } +//QTBUG-25139 +void tst_qquickbehaviors::multipleChangesToValueType() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("multipleChangesToValueType.qml")); + QScopedPointer rect(qobject_cast(c.create())); + QVERIFY(rect != 0); + + QQuickText *text = rect->findChild(); + QVERIFY(text != 0); + + QFont value; + value.setPointSize(24); + QCOMPARE(text->property("font").value(), value); + + QVERIFY(QMetaObject::invokeMethod(rect.data(), "updateFontProperties")); + + value.setItalic(true); + value.setWeight(QFont::Bold); + QCOMPARE(text->property("font").value(), value); + + value.setPointSize(48); + QTRY_COMPARE(text->property("font").value(), value); +} + QTEST_MAIN(tst_qquickbehaviors) #include "tst_qquickbehaviors.moc"