From a9b430b965896cfaafcf2078176209849bcc1c57 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 8 Aug 2025 14:53:50 +0200 Subject: 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 --- src/corelib/animation/qabstractanimation.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/corelib/animation/qabstractanimation.cpp') 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 - #include "qabstractanimation_p.h" -#include +#include +#include #include +#include +#include #include #include +#include #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(); } -- cgit v1.2.3