From 72ef272733d9b91c991233d826054cccb926db2d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 24 Feb 2015 21:13:06 +0100 Subject: [PATCH] (Re)introduce loopLevel into QThread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function used to reside in QEventLoop in Qt 3 and was deprecated in Qt 4. However this is useful for those who want to know how many event loops are running within the thread so we just make it possible to get at the already available variable. Change-Id: Ia6a7d94ff443a1d1577633363694bc2fa8eca7e4 Reviewed-by: Thiago Macieira Reviewed-by: Jørgen Lind --- src/corelib/thread/qthread.cpp | 13 +++++++++++++ src/corelib/thread/qthread.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index f119828e8e..acee337642 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -711,6 +711,19 @@ QThread::Priority QThread::priority() const \sa terminate() */ +/*! + Returns the current event loop level for the thread. + + \note This can only be called within the thread itself, i.e. when + it is the current thread. +*/ + +int QThread::loopLevel() const +{ + Q_D(const QThread); + return d->data->eventLoops.size(); +} + #else // QT_NO_THREAD QThread::QThread(QObject *parent) diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 72d8f5a5f8..58755b9625 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -90,6 +90,7 @@ public: void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); bool event(QEvent *event) Q_DECL_OVERRIDE; + int loopLevel() const; public Q_SLOTS: void start(Priority = InheritPriority);