From 3f5dc49edf41359f18e7c94c28a345a9600eb44f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 6 Dec 2012 16:48:15 -0600 Subject: Automated update from Qt3 --- src/kernel/qeventloop.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/kernel/qeventloop.cpp') 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 } /*! -- cgit v1.2.1