summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-02-03 15:37:42 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-12 20:12:17 +0100
commitaf8c35bda4fd245061e3a43df32f705903e855dd (patch)
tree1742505c3c7efe93cadaa6b7c8d7cd89aea9124c /src/corelib/kernel/qcoreapplication.h
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 <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.h')
-rw-r--r--src/corelib/kernel/qcoreapplication.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index c2843030fd..d8c52fbf1d 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -127,7 +127,9 @@ public:
static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
static void sendPostedEvents(QObject *receiver = 0, int event_type = 0);
static void removePostedEvents(QObject *receiver, int eventType = 0);
- static bool hasPendingEvents();
+#if QT_DEPRECATED_SINCE(5, 3)
+ QT_DEPRECATED static bool hasPendingEvents();
+#endif
static QAbstractEventDispatcher *eventDispatcher();
static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);