From 02f70004c266f4c35f098f49cfb3ca0284e28cac Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 5 Dec 2015 23:55:17 +0200 Subject: Allow socket events processing with a foreign event loop on Windows While a native dialog is open, the application message queue is handled by the native event loop which is external to Qt. In this case, QEventDispatcherWin32::processEvents() does not run and socket notifiers will not be activated. So, this patch moves the notifier activation code into the window procedure, which enables socket event processing with native dialogs. Task-number: QTBUG-49782 Task-number: QTBUG-48901 Change-Id: Icbdd96b2e80c50b73505f4fe74957575b83d6cf1 Reviewed-by: Oswald Buddenhagen Reviewed-by: Kai Koehne Reviewed-by: Joerg Bornemann --- .../gui/kernel/noqteventloop/tst_noqteventloop.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp') diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index d21569dcc0..735d23b137 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -36,6 +36,9 @@ #include #include #include +#include +#include +#include #include @@ -47,6 +50,7 @@ private slots: void initTestCase(); void cleanup(); void consumeMouseEvents(); + void consumeSocketEvents(); }; @@ -265,6 +269,36 @@ void tst_NoQtEventLoop::consumeMouseEvents() } +void tst_NoQtEventLoop::consumeSocketEvents() +{ + int argc = 1; + char *argv[] = { const_cast("test"), 0 }; + QGuiApplication app(argc, argv); + QTcpServer server; + QTcpSocket client; + + QVERIFY(server.listen(QHostAddress::LocalHost)); + client.connectToHost(server.serverAddress(), server.serverPort()); + QVERIFY(client.waitForConnected()); + + QElapsedTimer elapsedTimer; + elapsedTimer.start(); + + // Exec own message loop + MSG msg; + forever { + if (elapsedTimer.hasExpired(3000) || server.hasPendingConnections()) + break; + + if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } + + QVERIFY(server.hasPendingConnections()); +} + #include QTEST_APPLESS_MAIN(tst_NoQtEventLoop) -- cgit v1.2.3