diff options
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 9408d414f0..c30f6135a9 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -660,8 +660,10 @@ void QCoreApplication::init() d->createEventDispatcher(); Q_ASSERT(QCoreApplicationPrivate::eventDispatcher != 0); - if (!QCoreApplicationPrivate::eventDispatcher->parent()) + if (!QCoreApplicationPrivate::eventDispatcher->parent()) { QCoreApplicationPrivate::eventDispatcher->moveToThread(d->threadData->thread); + QCoreApplicationPrivate::eventDispatcher->setParent(this); + } d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher; @@ -2517,6 +2519,31 @@ bool QCoreApplication::hasPendingEvents() return false; } +/*! + Returns a pointer to the event dispatcher object for the main thread. If no + event dispatcher exists for the thread, this function returns 0. +*/ +QAbstractEventDispatcher *QCoreApplication::eventDispatcher() +{ + if (QCoreApplicationPrivate::theMainThread) + return QCoreApplicationPrivate::theMainThread->eventDispatcher(); + return 0; +} + +/*! + Sets the event dispatcher for the main thread to \a eventDispatcher. This + is only possible as long as there is no event dispatcher installed yet. That + is, before QCoreApplication has been instantiated. This method takes + ownership of the object. +*/ +void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) +{ + QThread *mainThread = QCoreApplicationPrivate::theMainThread; + if (!mainThread) + mainThread = QThread::currentThread(); // will also setup theMainThread + mainThread->setEventDispatcher(eventDispatcher); +} + /* \fn void QCoreApplication::watchUnixSignal(int signal, bool watch) \internal |