diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-08-08 14:53:50 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-08-29 12:26:40 +0000 |
| commit | a9b430b965896cfaafcf2078176209849bcc1c57 (patch) | |
| tree | f82a633c6a2fc09b02abb01d914f54aa03d385c0 | |
| parent | f85a398dc1482adce31f3799a89137182323ba44 (diff) | |
Destroy the QUnifiedTimer when the Q*Application gets destroyed
Cleanup the thread local instance of the QUnifiedTimer when
the QCoreApplication::aboutToQuit signal gets emitted.
This should make sure the QUnifiedTimer for the main thread
is destroyed and doesn't try to run any AnimationJobs which are
already deleted.
The quit() may be invoked from an animation. In that case, the
QUnifiedTimer still needs to survive its currently running
updateAnimationTimers(). Therefore, use deleteLater() rather than
deleting directly.
Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136629
Change-Id: I1608e566ee9b3ab313e82d3233fe455fd488b166
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| -rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 17814c6756a..3507e4e6bc7 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -106,17 +106,16 @@ \sa direction */ -#include "qabstractanimation.h" -#include "qanimationgroup.h" - -#include <QtCore/qdebug.h> - #include "qabstractanimation_p.h" -#include <QtCore/qmath.h> +#include <QtCore/qanimationgroup.h> +#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreevent.h> +#include <QtCore/qdebug.h> +#include <QtCore/qmath.h> #include <QtCore/qpointer.h> #include <QtCore/qscopedvaluerollback.h> +#include <QtCore/qthread.h> #define DEFAULT_TIMER_INTERVAL 16 #define PAUSE_TIMER_COARSE_THRESHOLD 2000 @@ -199,6 +198,10 @@ QUnifiedTimer *QUnifiedTimer::instance(bool create) if (create && !unifiedTimer) { inst = new QUnifiedTimer; unifiedTimer.reset(inst); + if (QThread::isMainThread()) { + connect(qApp, &QCoreApplication::aboutToQuit, inst, + []() { unifiedTimer.release()->deleteLater(); }); + } } else { inst = unifiedTimer.get(); } |
