From cd73301a2e088ee03d2b505a3eb4edc14e83fb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 18 Aug 2022 23:47:43 +0200 Subject: [PATCH] wasm: disable asyncify for non-static builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The asyncify support in the event loop currently uses EM_JS, which Emscripten does not support using from side modules. Change-Id: I5f961d9cd12f7b1b6cc1c2382b807a1da2918725 Reviewed-by: Lorn Potter Reviewed-by: MikoĊ‚aj Boc --- src/corelib/kernel/qeventdispatcher_wasm.cpp | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index 7ae29e616d..cd7d3583b4 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -32,6 +32,8 @@ Q_LOGGING_CATEGORY(lcEventDispatcherTimers, "qt.eventdispatcher.timers"); // track Qts own usage of asyncify. static bool g_is_asyncify_suspended = false; +#if defined(QT_STATIC) + EM_JS(bool, qt_have_asyncify_js, (), { return typeof Asyncify != "undefined"; }); @@ -54,6 +56,27 @@ EM_JS(void, qt_asyncify_resume_js, (), { setTimeout(wakeUp); }); +#else + +// EM_JS is not supported for side modules; disable asyncify + +bool qt_have_asyncify_js() +{ + return false; +} + +void qt_asyncify_suspend_js() +{ + Q_UNREACHABLE(); +} + +void qt_asyncify_resume_js() +{ + Q_UNREACHABLE(); +} + +#endif // defined(QT_STATIC) + // Returns true if asyncify is available. bool qt_have_asyncify() {