diff options
-rw-r--r-- | src/corelib/kernel/qabstracteventdispatcher.cpp | 6 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 11 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 11 |
3 files changed, 16 insertions, 12 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 { diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 9acf2c8..31d0b75 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -277,17 +277,6 @@ typedef struct tagGESTURECONFIG #endif // Q_WS_WIN -class QScopedLoopLevelCounter -{ - QThreadData *threadData; -public: - QScopedLoopLevelCounter(QThreadData *threadData) - : threadData(threadData) - { ++threadData->loopLevel; } - ~QScopedLoopLevelCounter() - { --threadData->loopLevel; } -}; - typedef QHash<QByteArray, QFont> FontHash; FontHash *qt_app_fonts_hash(); |