summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-07-10 17:45:17 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-07-19 19:40:51 +0300
commit74422bbf0256861899b73de908b45b1a8c8f1aae (patch)
tree2f6a1f99c79fd95d0c41ddac6f2647998e2c582e /src/corelib/kernel/qobject.cpp
parentfa42350c8dab14d479014a6b895c0a13ff283acd (diff)
QTimerInfoList: refactor unregisterTimers()
- Use removeIf(), easier to reason about than removing from the list during iteration - Return true only if any timers were actually unregistered - Assert in QObject::event() that if the list returned by eventDispatcher->registeredTimers() isn't empty, then eventDispatcher->unregisteredTimers() returns true Change-Id: I739a3865b7524a7aab3ff0227e6a060ed98d6191 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e53054b6d70..8a31633f38d 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1415,8 +1415,11 @@ bool QObject::event(QEvent *e)
if (eventDispatcher) {
QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this);
if (!timers.isEmpty()) {
+ const bool res = eventDispatcher->unregisterTimers(this);
// do not to release our timer ids back to the pool (since the timer ids are moving to a new thread).
- eventDispatcher->unregisterTimers(this);
+ Q_ASSERT_X(res, Q_FUNC_INFO,
+ "QAbstractEventDispatcher::unregisterTimers() returned false,"
+ " but there are timers associated with this object.");
QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
Q_ARG(void*, (new QList<QAbstractEventDispatcher::TimerInfo>(timers))));
}