summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventdispatcher_wasm.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp
index f5c2802aa6..c0d753c594 100644
--- a/src/corelib/kernel/qeventdispatcher_wasm.cpp
+++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp
@@ -567,16 +567,20 @@ void QEventDispatcherWasm::callProcessTimers(void *context)
}
#if QT_CONFIG(thread)
-// Runs a function on the main thread
-void QEventDispatcherWasm::runOnMainThread(std::function<void(void)> fn)
-{
- static auto trampoline = [](void *context) {
+
+namespace {
+ void trampoline(void *context) {
std::function<void(void)> *fn = reinterpret_cast<std::function<void(void)> *>(context);
(*fn)();
delete fn;
- };
+ }
+}
+
+// Runs a function on the main thread
+void QEventDispatcherWasm::runOnMainThread(std::function<void(void)> fn)
+{
void *context = new std::function<void(void)>(fn);
- emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, reinterpret_cast<void *>(&trampoline), context);
+ emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, reinterpret_cast<void *>(trampoline), context);
}
#endif