diff options
author | John Stanley <jpsinthemix@verizon.net> | 2012-01-30 12:27:49 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-10 15:11:54 (GMT) |
commit | 6bab6fccd2d8ee8e83e968864d729c1bbee39a66 (patch) | |
tree | 570406d5cfa34e47c95359a402b296ce36af3286 /src/corelib | |
parent | 69ada23a75bb51b4efc90c6128cce22d5ee6a779 (diff) | |
download | Qt-6bab6fccd2d8ee8e83e968864d729c1bbee39a66.zip Qt-6bab6fccd2d8ee8e83e968864d729c1bbee39a66.tar.gz Qt-6bab6fccd2d8ee8e83e968864d729c1bbee39a66.tar.bz2 |
Raise loopLevel for deleteLater in event filters
Change-Id: I163f510f6e99d86a35cc78965fa383e7f4618f42
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qabstracteventdispatcher.cpp | 6 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 3f73e61..3b0a258 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -532,8 +532,12 @@ QAbstractEventDispatcher::EventFilter QAbstractEventDispatcher::setEventFilter(E bool QAbstractEventDispatcher::filterEvent(void *message) { Q_D(QAbstractEventDispatcher); - if (d->event_filter) + if (d->event_filter) { + // Raise the loopLevel so that deleteLater() calls in or triggered + // by event_filter() will be processed from the main event loop. + QScopedLoopLevelCounter loopLevelCounter(d->threadData); return d->event_filter(message); + } return false; } diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 9b71d02..bb90de7 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -238,6 +238,17 @@ public: # endif }; +class QScopedLoopLevelCounter +{ + QThreadData *threadData; +public: + inline QScopedLoopLevelCounter(QThreadData *threadData) + : threadData(threadData) + { ++threadData->loopLevel; } + inline ~QScopedLoopLevelCounter() + { --threadData->loopLevel; } +}; + // thread wrapper for the main() thread class QAdoptedThread : public QThread { |