diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2021-05-20 13:01:15 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-06-23 06:57:32 +0000 |
commit | 713c2a7af6688b9cecf56a79514bc683273fb2e4 (patch) | |
tree | 2c52cf5fc89239a75b5e7cbb49a26fd918e5d79f /src/corelib | |
parent | 2e12c2caf5e32a3deda4c01afd96b362748b7c3e (diff) |
wasm: remove QEventLoop workarounds
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ø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qeventloop.cpp | 24 |
1 files changed, 0 insertions, 24 deletions
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 <private/qthread_p.h> -#ifdef Q_OS_WASM -#include <emscripten.h> -#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 } /*! |