diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-10 10:03:19 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-25 20:44:16 +0100 |
commit | 43114c97559a0b0dfb101f87d43cf52782bd6f63 (patch) | |
tree | 99882423e4ef3853f42192ac33e8bd12a9aa59e2 /tests/auto/qml/qqmlmetatype | |
parent | 0d8b27004812bca339df44372941a8415945d256 (diff) |
QML: Fix interceptors on value types ignoring fast changes
If a property is changed and reverted in short order, any animation
attached to it may not get a chance to take effect in between. In such a
case it looks like we don't have to update the interceptor when
reverting, but we actually have to. The animation needs to be canceled,
after all.
We now have to fix the case of writing different properties of a value
type sequentially, where one has an animation attached to it, though. If
that happens, we cannot drop the animation when a _different_ property
is written later on, but we do still have to update the whole value
type. So, pass an additional argument in the relevant metacalls that
declares the property we intended to change.
Pick-to: 6.5
Fixes: QTBUG-54860
Change-Id: I3b6cad2d4707d30312cda98283928fd419c40345
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qqmlmetatype')
-rw-r--r-- | tests/auto/qml/qqmlmetatype/data/animationOnValueType.qml | 26 | ||||
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 13 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/data/animationOnValueType.qml b/tests/auto/qml/qqmlmetatype/data/animationOnValueType.qml new file mode 100644 index 0000000000..196715dd74 --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/animationOnValueType.qml @@ -0,0 +1,26 @@ +import QtQuick + +Text { + property bool large: false + property bool check: false + font.pointSize: large ? 24 : 12 + font.letterSpacing: check ? 24 : 12 + + Behavior on font.pointSize { + SmoothedAnimation { duration: 100; } + } + + Behavior on font.letterSpacing { + SmoothedAnimation { duration: 100; } + } + + Component.onCompleted: { + large = true; + large = false; + check = true; + } + + property real pointSize: font.pointSize + property real letterSpacing: font.letterSpacing +} + diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 6f4221539d..c1bac33d87 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -49,6 +49,8 @@ private slots: void enumsInRecursiveImport_data(); void enumsInRecursiveImport(); + + void revertValueTypeAnimation(); }; class TestType : public QObject @@ -711,6 +713,17 @@ void tst_qqmlmetatype::enumsInRecursiveImport() QTRY_COMPARE(obj->property("color").toString(), QString("green")); } +void tst_qqmlmetatype::revertValueTypeAnimation() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("animationOnValueType.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QScopedPointer<QObject> o(c.create()); + QTRY_COMPARE(o->property("letterSpacing").toDouble(), 24.0); + QCOMPARE(o->property("pointSize").toDouble(), 12.0); +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" |