summaryrefslogtreecommitdiffstats
path: root/src/kernel/qeventloop.cpp
diff options
context:
space:
mode:
authorDarrell Anderson <humanreadable@yahoo.com>2012-12-19 14:03:09 -0600
committerDarrell Anderson <humanreadable@yahoo.com>2012-12-19 14:03:09 -0600
commit35202ed0d899a9ff3c77dad72b501fb30e4dcf93 (patch)
tree683787f69d937483b860973ce17f0c5d430a142d /src/kernel/qeventloop.cpp
parent8d5add0e87ad913bdf0362a83f431995115f3bfa (diff)
parentf19aa203c934d0f85862fdf810a87fe7c5777d17 (diff)
downloadqt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.tar.gz
qt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.zip
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src/kernel/qeventloop.cpp')
-rw-r--r--src/kernel/qeventloop.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/kernel/qeventloop.cpp b/src/kernel/qeventloop.cpp
index 1f6a130..5eadb9e 100644
--- a/src/kernel/qeventloop.cpp
+++ b/src/kernel/qeventloop.cpp
@@ -41,6 +41,11 @@
#include "qapplication.h"
#include "qdatetime.h"
+#ifdef QT_THREAD_SUPPORT
+# include "qthread.h"
+# include "qthreadinstance_p.h"
+#endif
+
/*!
\class QEventLoop
\brief The QEventLoop class manages the event queue.
@@ -100,15 +105,27 @@ QEventLoop::QEventLoop( QObject *parent, const char *name )
: QObject( parent, name )
{
#if defined(QT_CHECK_STATE)
- if ( QApplication::eventloop )
- qFatal( "QEventLoop: there must be only one event loop object. \nConstruct it before QApplication." );
- // for now ;)
+ if ( QApplication::currentEventLoop() )
+ qFatal( "QEventLoop: there must be only one event loop object per thread. \nIf this is supposed to be the main GUI event loop, construct it before QApplication." );
+ if (!QThread::currentThreadObject()) {
+ qFatal( "QEventLoop: this object can only be used in threads constructed via QThread." );
+ }
#endif // QT_CHECK_STATE
d = new QEventLoopPrivate;
init();
+
+#ifdef QT_THREAD_SUPPORT
+ QThread* thread = QThread::currentThreadObject();
+ if (thread) {
+ if (thread->d) {
+ thread->d->eventLoop = this;
+ }
+ }
+#else
QApplication::eventloop = this;
+#endif
}
/*!
@@ -118,7 +135,16 @@ QEventLoop::~QEventLoop()
{
cleanup();
delete d;
+#ifdef QT_THREAD_SUPPORT
+ QThread* thread = QThread::currentThreadObject();
+ if (thread) {
+ if (thread->d) {
+ thread->d->eventLoop = 0;
+ }
+ }
+#else
QApplication::eventloop = 0;
+#endif
}
/*!