summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/animation
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2021-04-23 14:31:26 +0200
committerAndreas Buhr <andreas.buhr@qt.io>2021-04-28 12:38:57 +0200
commitbb5d2af7677a14f2aaeffb0e29679d9dcce692e6 (patch)
tree8460a0cead7134a2d203eb6fe46c414ce8afa05b /tests/auto/corelib/animation
parentab43506910ebb520872afb42b641edae4c07808c (diff)
Port QPropertyAnimation::targetObject to bindable properties
This is one of the more complicated ports. The target object was represented by two variables in the past: A raw pointer and a QPointer. The QPointer is checked in some cases to check whether the target object still exists. This patch introduces a targetObjectDestroyed() slot and connects it to the destroyed(QObject*) signal of the target object. In this slot, the animation is stopped. The checks become obsolete thereby and it is sufficient to represent the target Object in one raw pointer. This raw pointer becomes a bindable property. Fixes: QTBUG-92992 Change-Id: I7e2ddb5d8aed007400fe74bea1becf7bdfbf2563 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/corelib/animation')
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index 5286daec6a..1da69f8338 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -1403,11 +1403,26 @@ void tst_QPropertyAnimation::recursiveAnimations()
void tst_QPropertyAnimation::bindings()
{
- AnimationObject o;
- QPropertyAnimation a(&o, "value");
+ std::unique_ptr<AnimationObject> o1(new AnimationObject);
+ std::unique_ptr<AnimationObject> o2(new AnimationObject);
+ QPropertyAnimation a(o1.get(), "value");
+
+ QTestPrivate::testReadWritePropertyBasics<QPropertyAnimation, QByteArray>(
+ a, QByteArray("realValue"), QByteArray("value"), "propertyName");
+ if (QTest::currentTestFailed()) {
+ qDebug() << "Failed property test for QPropertyAnimation::propertyName";
+ return;
+ }
+ QTestPrivate::testReadWritePropertyBasics<QPropertyAnimation, QObject *>(a, o2.get(), o1.get(),
+ "targetObject");
+ if (QTest::currentTestFailed()) {
+ qDebug() << "Failed property test for QPropertyAnimation::targetObject";
+ return;
+ }
- QTestPrivate::testReadWritePropertyBasics(a, QByteArray("value"), QByteArray("realValue"),
- "propertyName");
+ a.setTargetObject(o1.get());
+ o1.reset();
+ QCOMPARE(a.targetObject(), nullptr);
}
QTEST_MAIN(tst_QPropertyAnimation)