mirror of https://github.com/qt/qtbase.git
Revert "Destroy the QUnifiedTimer when the Q*Application gets destroyed"
This reverts commita9b430b965
. The reproducer of QTBUG-136629 shows an animation timer being deleted without unregistering itself from the QUnifiedTimer driving it. It's clearly the animation timer's responsibility to notify the QUnifiedTimer about its deletion. Deleting the QUnifiedTimer on application shutdown happens to fix the problem in this case, but is in no way a generic solution to the issue of deleted animation timers leaving dangling pointers in QUnifiedTimer. Furthermore, prematurely deleting the QUnifiedTimer is an overt behavior change. Before this, you could leave animations running across exec/quit cycles of the QCoreApplication. When the QUnifiedTimer is deleted on quitting the QCoreApplication, this is not possible anymore. The QtStateMachine tests exercise this behavior. Instead of working around the problem in QtCore, the offending animation timer should simply unregister itself. This is a fix to be applied to QtQml. Fixes: QTBUG-139989 Fixes: QTBUG-140159 Change-Id: I72acc9af5f7126e068600a4dfd581f9784713804 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commitbcefe20119
) Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
This commit is contained in:
parent
3bf22a2abb
commit
9ad6ee42dd
|
@ -106,16 +106,17 @@
|
|||
\sa direction
|
||||
*/
|
||||
|
||||
#include "qabstractanimation.h"
|
||||
#include "qanimationgroup.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include "qabstractanimation_p.h"
|
||||
|
||||
#include <QtCore/qanimationgroup.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qscopedvaluerollback.h>
|
||||
#include <QtCore/qthread.h>
|
||||
|
||||
#define DEFAULT_TIMER_INTERVAL 16
|
||||
#define PAUSE_TIMER_COARSE_THRESHOLD 2000
|
||||
|
@ -198,10 +199,6 @@ 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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue