summaryrefslogtreecommitdiffstats
path: root/src/kernel/qeventloop.cpp
diff options
context:
space:
mode:
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 4824f5717..e13a0e92a 100644
--- a/src/kernel/qeventloop.cpp
+++ b/src/kernel/qeventloop.cpp
@@ -41,6 +41,11 @@
#include "ntqapplication.h"
#include "ntqdatetime.h"
+#ifdef QT_THREAD_SUPPORT
+# include "ntqthread.h"
+# include "qthreadinstance_p.h"
+#endif
+
/*!
\class TQEventLoop
\brief The TQEventLoop class manages the event queue.
@@ -100,15 +105,27 @@ TQEventLoop::TQEventLoop( TQObject *parent, const char *name )
: TQObject( parent, name )
{
#if defined(QT_CHECK_STATE)
- if ( TQApplication::eventloop )
- tqFatal( "TQEventLoop: there must be only one event loop object. \nConstruct it before TQApplication." );
- // for now ;)
+ if ( TQApplication::currentEventLoop() )
+ tqFatal( "TQEventLoop: there must be only one event loop object per thread. \nIf this is supposed to be the main GUI event loop, construct it before TQApplication." );
+ if (!TQThread::currentThreadObject()) {
+ tqFatal( "TQEventLoop: this object can only be used in threads constructed via TQThread." );
+ }
#endif // QT_CHECK_STATE
d = new TQEventLoopPrivate;
init();
+
+#ifdef QT_THREAD_SUPPORT
+ TQThread* thread = TQThread::currentThreadObject();
+ if (thread) {
+ if (thread->d) {
+ thread->d->eventLoop = this;
+ }
+ }
+#else
TQApplication::eventloop = this;
+#endif
}
/*!
@@ -118,7 +135,16 @@ TQEventLoop::~TQEventLoop()
{
cleanup();
delete d;
+#ifdef QT_THREAD_SUPPORT
+ TQThread* thread = TQThread::currentThreadObject();
+ if (thread) {
+ if (thread->d) {
+ thread->d->eventLoop = 0;
+ }
+ }
+#else
TQApplication::eventloop = 0;
+#endif
}
/*!