diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-13 09:25:20 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-13 09:25:20 (GMT) |
commit | b664d54867139b371e158f1c63076c4a970cbb2a (patch) | |
tree | 455de47287676160557b40fc67ea3d6c0f15f209 | |
parent | 99b19431e6846a36a65f23d21a95140a081d1f1a (diff) | |
parent | c785d92153d23b836451b0643424b9871bcc4be9 (diff) | |
download | Qt-b664d54867139b371e158f1c63076c4a970cbb2a.zip Qt-b664d54867139b371e158f1c63076c4a970cbb2a.tar.gz Qt-b664d54867139b371e158f1c63076c4a970cbb2a.tar.bz2 |
Merge commit 'c785d92153d23b836451b0643424b9871bcc4be9' into 4.6-upstream
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_win.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qcoreapplication/tst_qcoreapplication.cpp | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 3050b82..0518e24 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -675,6 +675,11 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) bool seenWM_QT_SENDPOSTEDEVENTS = false; bool needWM_QT_SENDPOSTEDEVENTS = false; do { + if (! (flags & QEventLoop::EventLoopExec)) { + // when called "manually", always send posted events + QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + } + DWORD waitRet = 0; HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1]; QVarLengthArray<MSG> processedTimers; diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index c5f06e2..3c61f81 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -58,6 +58,7 @@ private slots: #endif void applicationPid(); void globalPostedEventsCount(); + void processEventsAlwaysSendsPostedEvents(); }; class EventSpy : public QObject @@ -488,5 +489,40 @@ void tst_QCoreApplication::globalPostedEventsCount() QCOMPARE(x.globalPostedEventsCount, expected); } +class ProcessEventsAlwaysSendsPostedEventsObject : public QObject +{ +public: + int counter; + + inline ProcessEventsAlwaysSendsPostedEventsObject() + : counter(0) + { } + + bool event(QEvent *event) + { + if (event->type() == QEvent::User) + ++counter; + return QObject::event(event); + } +}; + +void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + ProcessEventsAlwaysSendsPostedEventsObject object; + QTime t; + t.start(); + int i = 1; + do { + QCoreApplication::postEvent(&object, new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(object.counter, i); + ++i; + } while (t.elapsed() < 3000); +} + QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" |