summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stanley <jpsinthemix@verizon.net>2012-01-30 12:27:49 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-10 15:11:54 (GMT)
commit6bab6fccd2d8ee8e83e968864d729c1bbee39a66 (patch)
tree570406d5cfa34e47c95359a402b296ce36af3286
parent69ada23a75bb51b4efc90c6128cce22d5ee6a779 (diff)
downloadQt-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>
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp6
-rw-r--r--src/corelib/thread/qthread_p.h11
-rw-r--r--src/gui/kernel/qapplication_p.h11
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();