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 /src/qml/qml/qqmlproperty.cpp | |
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 'src/qml/qml/qqmlproperty.cpp')
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index cfdcc9ea60..18e2c417ff 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1271,29 +1271,31 @@ static void removeValuePropertyBinding( template<typename Op> bool changePropertyAndWriteBack( QObject *object, int coreIndex, QQmlGadgetPtrWrapper *wrapper, - QQmlPropertyData::WriteFlags flags, Op op) + QQmlPropertyData::WriteFlags flags, int internalIndex, Op op) { wrapper->read(object, coreIndex); const bool rv = op(wrapper); - wrapper->write(object, coreIndex, flags); + wrapper->write(object, coreIndex, flags, internalIndex); return rv; } template<typename Op> bool changeThroughGadgetPtrWrapper( - QObject *object, const QQmlPropertyData &core, - const QQmlRefPointer<QQmlContextData> &context, QQmlPropertyData::WriteFlags flags, - Op op) + QObject *object, const QQmlPropertyData &core, + const QQmlRefPointer<QQmlContextData> &context, QQmlPropertyData::WriteFlags flags, + int internalIndex, Op op) { if (QQmlGadgetPtrWrapper *wrapper = context ? QQmlGadgetPtrWrapper::instance(context->engine(), core.propType()) : nullptr) { - return changePropertyAndWriteBack(object, core.coreIndex(), wrapper, flags, op); + return changePropertyAndWriteBack( + object, core.coreIndex(), wrapper, flags, internalIndex, op); } if (QQmlValueType *valueType = QQmlMetaType::valueType(core.propType())) { QQmlGadgetPtrWrapper wrapper(valueType, nullptr); - return changePropertyAndWriteBack(object, core.coreIndex(), &wrapper, flags, op); + return changePropertyAndWriteBack( + object, core.coreIndex(), &wrapper, flags, internalIndex, op); } return false; @@ -1309,8 +1311,9 @@ bool QQmlPropertyPrivate::writeValueProperty( if (!valueTypeData.isValid()) return write(object, core, value, context, flags); - return changeThroughGadgetPtrWrapper(object, core, context, flags, - [&](QQmlGadgetPtrWrapper *wrapper) { + return changeThroughGadgetPtrWrapper( + object, core, context, flags | QQmlPropertyData::HasInternalIndex, + valueTypeData.coreIndex(), [&](QQmlGadgetPtrWrapper *wrapper) { return write(wrapper, valueTypeData, value, context, flags); }); } @@ -1324,8 +1327,9 @@ bool QQmlPropertyPrivate::resetValueProperty( if (!valueTypeData.isValid()) return reset(object, core, flags); - return changeThroughGadgetPtrWrapper(object, core, context, flags, - [&](QQmlGadgetPtrWrapper *wrapper) { + return changeThroughGadgetPtrWrapper( + object, core, context, flags | QQmlPropertyData::HasInternalIndex, + valueTypeData.coreIndex(), [&](QQmlGadgetPtrWrapper *wrapper) { return reset(wrapper, valueTypeData, flags); }); } |