diff options
Diffstat (limited to 'src/corelib/kernel')
| -rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 22 | ||||
| -rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix.cpp | 2 | ||||
| -rw-r--r-- | src/corelib/kernel/qeventloop.cpp | 24 |
3 files changed, 47 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0303916c113..1350a7aa946 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -118,6 +118,10 @@ # include <taskLib.h> #endif +#ifdef Q_OS_WASM +#include <emscripten.h> +#endif + #ifdef QT_BOOTSTRAPPED #include <private/qtrace_p.h> #else @@ -486,6 +490,13 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint QCoreApplicationPrivate::~QCoreApplicationPrivate() { +#ifdef Q_OS_WASM + EM_ASM( + // unmount persistent directory as IDBFS + // see also QTBUG-70002 + FS.unmount('/home/web_user'); + ); +#endif #ifndef QT_NO_QOBJECT cleanupThreadData(); #endif @@ -777,6 +788,17 @@ void QCoreApplicationPrivate::init() Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = q; +#ifdef Q_OS_WASM + EM_ASM( + // mount and sync persistent filesystem to sandbox + FS.mount(IDBFS, {}, '/home/web_user'); + FS.syncfs(true, function(err) { + if (err) + Module.print(err); + }); + ); +#endif + // Store app name/version (so they're still available after QCoreApplication is destroyed) if (!coreappdata()->applicationNameSet) coreappdata()->application = appName(); diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index a28f2e3f0a9..535f86fefe5 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -130,7 +130,7 @@ static void initThreadPipeFD(int fd) bool QThreadPipe::init() { -#if defined(Q_OS_NACL) +#if defined(Q_OS_NACL) || defined(Q_OS_WASM) // do nothing. #elif defined(Q_OS_VXWORKS) qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf())); diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index f1d32b15d19..a6cc51621a4 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -48,6 +48,10 @@ #include "qeventloop_p.h" #include <private/qthread_p.h> +#ifdef Q_OS_WASM +#include <emscripten.h> +#endif + QT_BEGIN_NAMESPACE /*! @@ -208,6 +212,15 @@ 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 (d->threadData->loopLevel > 1) + emscripten_sleep(1); +#endif + while (!d->exit.loadAcquire()) processEvents(flags | WaitForMoreEvents | EventLoopExec); @@ -269,6 +282,17 @@ void QEventLoop::exit(int returnCode) d->returnCode.store(returnCode); d->exit.storeRelease(true); d->threadData->eventDispatcher.load()->interrupt(); + +#ifdef Q_OS_WASM + // QEventLoop::exec() never returns in emscripten. We implement approximate behavior here. + // QTBUG-70185 + if (d->threadData->loopLevel == 1) { + emscripten_force_exit(returnCode); + } else { + d->inExec = false; + --d->threadData->loopLevel; + } +#endif } /*! |
