summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread/qthread_p.h')
-rw-r--r--src/corelib/thread/qthread_p.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index d8374e9805..6597b56893 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -60,6 +60,7 @@
#include "QtCore/qstack.h"
#include "QtCore/qwaitcondition.h"
#include "QtCore/qmap.h"
+#include "QtCore/qcoreapplication.h"
#include "private/qobject_p.h"
@@ -144,6 +145,7 @@ public:
~QThreadPrivate();
mutable QMutex mutex;
+ QAtomicInt quitLockRef;
bool running;
bool finished;
@@ -179,6 +181,18 @@ public:
QThreadData *data;
static void createEventDispatcher(QThreadData *data);
+
+ void ref()
+ {
+ quitLockRef.ref();
+ }
+
+ void deref()
+ {
+ if (!quitLockRef.deref() && running) {
+ QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+ }
+ }
};
#else // QT_NO_THREAD
@@ -195,6 +209,9 @@ public:
static QThread *threadForId(int) { return QThread::currentThread(); }
static void createEventDispatcher(QThreadData *data);
+ void ref() {}
+ void deref() {}
+
Q_DECLARE_PUBLIC(QThread)
};