diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2019-11-08 19:37:51 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2019-11-13 10:10:13 +0200 |
commit | 79a1fc0e0106d125b467b603087137fdff5401f4 (patch) | |
tree | 2958150a0e37ff8ea5b5c67beecbaa28f875cc1c /src/corelib/kernel/qbasictimer.cpp | |
parent | 38f38c718895ba01a79c823a2ace6d9f27e12e85 (diff) |
QBasicTimer: release timer id on exit
In some cases of inheritance, timer deletion can be triggered from the
event dispatcher destructor where QThreadData::eventDispatcher is
already nullptr. Despite the fact that the application is in shutdown
phase, we should free the resource.
Change-Id: I61ed1d817fd7638953f7d629823f19d4f6f1ee00
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qbasictimer.cpp')
-rw-r--r-- | src/corelib/kernel/qbasictimer.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp index ea8f8e2c77..623ecb9b8b 100644 --- a/src/corelib/kernel/qbasictimer.cpp +++ b/src/corelib/kernel/qbasictimer.cpp @@ -216,13 +216,11 @@ void QBasicTimer::stop() { if (id) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (eventDispatcher) { - if (Q_UNLIKELY(!eventDispatcher->unregisterTimer(id))) { - qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread"); - return; - } - QAbstractEventDispatcherPrivate::releaseTimerId(id); + if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) { + qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread"); + return; } + QAbstractEventDispatcherPrivate::releaseTimerId(id); } id = 0; } |