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;
--- /dev/null
+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
+ }
+}
void sameValue();
void delayedRegistration();
void startOnCompleted();
+ void multipleChangesToValueType();
};
void tst_qquickbehaviors::simpleBehavior()
delete rect;
}
+//QTBUG-25139
+void tst_qquickbehaviors::multipleChangesToValueType()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("multipleChangesToValueType.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle *>(c.create()));
+ QVERIFY(rect != 0);
+
+ QQuickText *text = rect->findChild<QQuickText *>();
+ QVERIFY(text != 0);
+
+ QFont value;
+ value.setPointSize(24);
+ QCOMPARE(text->property("font").value<QFont>(), value);
+
+ QVERIFY(QMetaObject::invokeMethod(rect.data(), "updateFontProperties"));
+
+ value.setItalic(true);
+ value.setWeight(QFont::Bold);
+ QCOMPARE(text->property("font").value<QFont>(), value);
+
+ value.setPointSize(48);
+ QTRY_COMPARE(text->property("font").value<QFont>(), value);
+}
+
QTEST_MAIN(tst_qquickbehaviors)
#include "tst_qquickbehaviors.moc"