From 713c2a7af6688b9cecf56a79514bc683273fb2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 20 May 2021 13:01:15 +0200 Subject: wasm: remove QEventLoop workarounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In general, QEventLoop::exec() _can_ be used as-is on WebAssembly, provided that the event dispatcher supports the use case. Use cases that can work include calling exec() on a secondary thread, or calling exec() on the main thread if asyncify is used. Some use cases will still require special casing for Wasm, such as the non-asyncified QApplication::exec(), but that can be handles closer to where the workarounds needed, for example in QApplication. This removes the partial support for nested event loops on the main thread, which did not really work. Also, we no longer call emscripten_force_exit() on QEvetLoop::exit(), which makes it possible to exit a top-level event loop without exiting the process. Task-number: QTBUG-70185 Change-Id: I3a28f41b8547ed3ba1bdf6a835e6662483e34449 Reviewed-by: Tor Arne Vestbø Reviewed-by: Lorn Potter --- src/corelib/kernel/qeventloop.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index 3dc06242a3..8aa5a219fa 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -48,10 +48,6 @@ #include "qeventloop_p.h" #include -#ifdef Q_OS_WASM -#include -#endif - QT_BEGIN_NAMESPACE /*! @@ -219,15 +215,6 @@ int QEventLoop::exec(ProcessEventsFlags flags) if (app && app->thread() == thread()) QCoreApplication::removePostedEvents(app, QEvent::Quit); -#ifdef Q_OS_WASM - // Partial support for nested event loops: Make the runtime throw a JavaSrcript - // exception, which returns control to the browser while preserving the C++ stack. - // Event processing then continues as normal. The sleep call below never returns. - // QTBUG-70185 - if (threadData->loopLevel > 1) - emscripten_sleep(1); -#endif - while (!d->exit.loadAcquire()) processEvents(flags | WaitForMoreEvents | EventLoopExec); @@ -290,17 +277,6 @@ void QEventLoop::exit(int returnCode) d->returnCode.storeRelaxed(returnCode); d->exit.storeRelease(true); threadData->eventDispatcher.loadRelaxed()->interrupt(); - -#ifdef Q_OS_WASM - // QEventLoop::exec() never returns in emscripten. We implement approximate behavior here. - // QTBUG-70185 - if (threadData->loopLevel == 1) { - emscripten_force_exit(returnCode); - } else { - d->inExec = false; - --threadData->loopLevel; - } -#endif } /*! -- cgit v1.2.3