QVariantAnimation: fix binding loops

Rewrite the logic of the setters to use removeBindingUnlessInWrapper()
and {set}ValueBypassingBindings() calls.

The logic of both setters didn't change, because previously the
pre-existing bindings were implicitly removed when calling the
assignment operator.
The new code just makes it explicit.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I475e6cd65fc73796176f257835cb67b9e70a1e34
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Ivan Solovev 2023-08-25 14:37:14 +02:00
parent b6b94111c7
commit df9651c3fc

View File

@ -353,8 +353,9 @@ QEasingCurve QVariantAnimation::easingCurve() const
void QVariantAnimation::setEasingCurve(const QEasingCurve &easing)
{
Q_D(QVariantAnimation);
const bool valueChanged = easing != d->easing;
d->easing = easing;
d->easing.removeBindingUnlessInWrapper();
const bool valueChanged = easing != d->easing.valueBypassingBindings();
d->easing.setValueBypassingBindings(easing);
d->recalculateCurrentInterval();
if (valueChanged)
d->easing.notify();
@ -482,13 +483,12 @@ void QVariantAnimation::setDuration(int msecs)
qWarning("QVariantAnimation::setDuration: cannot set a negative duration");
return;
}
if (d->duration == msecs) {
d->duration.removeBindingUnlessInWrapper();
return;
d->duration.removeBindingUnlessInWrapper();
if (d->duration.valueBypassingBindings() != msecs) {
d->duration.setValueBypassingBindings(msecs);
d->recalculateCurrentInterval();
d->duration.notify();
}
d->duration = msecs;
d->recalculateCurrentInterval();
d->duration.notify();
}
QBindable<int> QVariantAnimation::bindableDuration()