From 52fd8c716e06e0a10bb4f31d6905f4b38948318d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 22 Aug 2024 22:07:16 +0300 Subject: [PATCH] tst_Q*AnimationGroup: use QBasicTimer instead of handling raw timer ids Change-Id: I1392a62e358e8367c24f3db839d53fc0b072483a Reviewed-by: Thiago Macieira --- .../qanimationgroup/tst_qanimationgroup.cpp | 14 ++++++++------ .../tst_qparallelanimationgroup.cpp | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 5345283252b..1dd21bb2a70 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -8,9 +8,12 @@ #include #include +#include #include #include +using namespace std::chrono_literals; + Q_DECLARE_METATYPE(QAbstractAnimation::State) class tst_QAnimationGroup : public QObject @@ -72,7 +75,7 @@ class UncontrolledAnimation : public QPropertyAnimation Q_OBJECT public: UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr) - : QPropertyAnimation(target, propertyName, parent), id(0) + : QPropertyAnimation(target, propertyName, parent) { setDuration(250); } @@ -82,22 +85,21 @@ public: protected: void timerEvent(QTimerEvent *event) override { - if (event->timerId() == id) + if (event->id() == timer.id()) stop(); } void updateRunning(bool running) { if (running) { - id = startTimer(500); + timer.start(500ms, this); } else { - killTimer(id); - id = 0; + timer.stop(); } } private: - int id; + QBasicTimer timer; }; void tst_QAnimationGroup::emptyGroup() diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index c47ce533641..d8da8ecc03b 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -6,9 +6,12 @@ #include #include +#include #include #include +using namespace std::chrono_literals; + Q_DECLARE_METATYPE(QAbstractAnimation::State) class tst_QParallelAnimationGroup : public QObject @@ -107,7 +110,7 @@ class UncontrolledAnimation : public QPropertyAnimation Q_OBJECT public: UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr) - : QPropertyAnimation(target, propertyName, parent), id(0) + : QPropertyAnimation(target, propertyName, parent) { setDuration(250); setEndValue(0); @@ -118,22 +121,21 @@ public: protected: void timerEvent(QTimerEvent *event) override { - if (event->timerId() == id) + if (event->id() == timer.id()) stop(); } void updateRunning(bool running) { if (running) { - id = startTimer(500); + timer.start(500ms, this); } else { - killTimer(id); - id = 0; + timer.stop(); } } private: - int id; + QBasicTimer timer; }; void tst_QParallelAnimationGroup::setCurrentTime()