summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-08-25 17:21:11 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-09-03 18:20:18 +0200
commitb64e36240b807e6dba783732593036439fec8a62 (patch)
treef9f0ab2e300507f7c2882a84daf5c7cd929014ba
parentdf9651c3fcdd026255add31744b2f75dc2ecdd62 (diff)
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>
-rw-r--r--src/corelib/animation/qpauseanimation.cpp7
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp7
3 files changed, 11 insertions, 4 deletions
diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp
index eb1e6c3c81b..344b21946e3 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -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();
}
}
diff --git a/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt b/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt
index 227dc998e42..aa0cb1edc5f 100644
--- a/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt
+++ b/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt
@@ -16,4 +16,5 @@ qt_internal_add_test(tst_qpauseanimation
tst_qpauseanimation.cpp
LIBRARIES
Qt::CorePrivate
+ Qt::TestPrivate
)
diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
index 53c80ef71f4..90357ef4776 100644
--- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
+++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
@@ -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)