Last active
December 23, 2015 00:09
-
-
Save torarnv/6551697 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool QUnixEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) | |
{ | |
const bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(flags); | |
if (QEventDispatcherUNIX::processEvents(flags)) { | |
return true; | |
} | |
return didSendEvents; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp w/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp | |
index 93cf799..8ca7858 100644 | |
--- i/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp | |
+++ w/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp | |
@@ -78,6 +78,7 @@ private slots: | |
/* void registerEventNotifiier(); */ // Not implemented here, see tst_QWinEventNotifier instead | |
void sendPostedEvents_data(); | |
void sendPostedEvents(); | |
+ void processEventsOnlySendsQueuedEvents(); | |
}; | |
bool tst_QEventDispatcher::event(QEvent *e) | |
@@ -207,5 +208,49 @@ void tst_QEventDispatcher::sendPostedEvents() | |
} | |
} | |
+class ProcessEventsOnlySendsQueuedEvents : public QObject | |
+{ | |
+ Q_OBJECT | |
+public: | |
+ int eventsReceived; | |
+ | |
+ inline ProcessEventsOnlySendsQueuedEvents() : eventsReceived(0) {} | |
+ | |
+ bool event(QEvent *event) | |
+ { | |
+ ++eventsReceived; | |
+ | |
+ if (event->type() == QEvent::User) | |
+ QCoreApplication::postEvent(this, new QEvent(QEvent::Type(QEvent::User + 1))); | |
+ | |
+ return QObject::event(event); | |
+ } | |
+public slots: | |
+ void timerFired() | |
+ { | |
+ QCoreApplication::postEvent(this, new QEvent(QEvent::Type(QEvent::User + 1))); | |
+ } | |
+}; | |
+ | |
+void tst_QEventDispatcher::processEventsOnlySendsQueuedEvents() | |
+{ | |
+ ProcessEventsOnlySendsQueuedEvents object; | |
+ | |
+ // Posted events during event processing should be handled on | |
+ // the next processEvents iteration. | |
+ QCoreApplication::postEvent(&object, new QEvent(QEvent::User)); | |
+ QCoreApplication::processEvents(); | |
+ QCOMPARE(object.eventsReceived, 1); | |
+ QCoreApplication::processEvents(); | |
+ QCOMPARE(object.eventsReceived, 2); | |
+ | |
+ // The same goes for posted events during timer processing | |
+ QTimer::singleShot(0, &object, SLOT(timerFired())); | |
+ QCoreApplication::processEvents(); | |
+ QCOMPARE(object.eventsReceived, 3); | |
+ QCoreApplication::processEvents(); | |
+ QCOMPARE(object.eventsReceived, 4); | |
+} | |
+ | |
QTEST_MAIN(tst_QEventDispatcher) | |
#include "tst_qeventdispatcher.moc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment