QPauseAnimation: extend tests and fix binding loop

Extend the unit-tests for bindable properties and fix the discovered
binding loop by using {set}ValueBypassingBindings() in the setter of
the duration property.

The code refactoring does not modify the setter logic, because
previously the binding was anyway implicitly removed when calling the
assignment operator. The updated code just does it explicitly.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I0f339d182efb60500ee7f12e407f200d739da312
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Ivan Solovev 2023-08-25 17:21:11 +02:00
parent df9651c3fc
commit b64e36240b
3 changed files with 11 additions and 4 deletions

View File

@ -94,11 +94,10 @@ void QPauseAnimation::setDuration(int msecs)
}
Q_D(QPauseAnimation);
if (msecs != d->duration) {
d->duration = msecs;
d->duration.removeBindingUnlessInWrapper();
if (msecs != d->duration.valueBypassingBindings()) {
d->duration.setValueBypassingBindings(msecs);
d->duration.notify();
} else {
d->duration.removeBindingUnlessInWrapper();
}
}

View File

@ -16,4 +16,5 @@ qt_internal_add_test(tst_qpauseanimation
tst_qpauseanimation.cpp
LIBRARIES
Qt::CorePrivate
Qt::TestPrivate
)

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QtTest/private/qpropertytesthelper_p.h>
#include <QtCore/qpauseanimation.h>
#include <QtCore/qpropertyanimation.h>
@ -456,6 +457,12 @@ void tst_QPauseAnimation::bindings()
"QPauseAnimation::setDuration: cannot set a negative duration");
animation.setDuration(-1);
QCOMPARE(durationObserver, 46);
QTestPrivate::testReadWritePropertyBasics(animation, 10, 20, "duration");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QPauseAnimation::duration");
return;
}
}
QTEST_MAIN(tst_QPauseAnimation)