path: root/src/corelib/kernel/qabstracteventdispatcher.cpp
diff options
authorThiago Macieira <>2014-02-03 15:37:42 -0800
committerThe Qt Project <>2014-02-12 20:12:17 +0100
commitaf8c35bda4fd245061e3a43df32f705903e855dd (patch)
tree1742505c3c7efe93cadaa6b7c8d7cd89aea9124c /src/corelib/kernel/qabstracteventdispatcher.cpp
parent1bf9f725d19664e7b28857986acefbfdb2b12162 (diff)
Deprecate {QCoreApp,QAbstractEventDispatcher}::hasPendingEvents()
This function has a flawed design. It was flawed when it was added in Qt 3.0. A "false" return value is racy: any other thread running may post events to the current thread, thus making the result stale. That includes Qt starts for its own purposes when it comes to the main thread, like the Scene Graph thread, the QProcessManager thread, the Windows QAdoptedThread watcher thread, the Windows pipe writer thread, etc. A "true" return is stable only if the selected thread is stopped, which includes selecting the current thread (the case of QCoreApplication). For that reason, this method should not be public, but a protected one so that a public static could call it. But even that would not solve the race condition from the previous paragraph (hence why QCoreApplication::hasPendingEvents being deprecated too). And, to top all of that off, all but one of the implementations access the GUI thread's event loop counter in a non-thread-safe manner. I've changed the documentation to restrict to the only currently-working use- application. [ChangeLog][QtCore][Event loop] QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are now deprecated. Please refer to the documentation for more information. Task-number: QTBUG-36611 Change-Id: Iac61f307e9672839944ae2f75abb1aea30c419f6 Reviewed-by: Giuseppe D'Angelo <>
Diffstat (limited to 'src/corelib/kernel/qabstracteventdispatcher.cpp')
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index 54524fa55b..90e3a1e9e1 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -210,9 +210,11 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread)
/*! \fn bool QAbstractEventDispatcher::hasPendingEvents()
+ \deprecated
- Returns \c true if there is an event waiting; otherwise returns
- false.
+ Returns \c true if there is an event waiting; otherwise returns false. This
+ function is an implementation detail for
+ QCoreApplication::hasPendingEvents() and must not be called directly.