Do not call processEvents async with JSPI enabled on WASM

With JSPI, the main dispatcher loop is not exited and processEvents
should not be called, as events will get processed after the thread has
been unsuspended. processEvents posted with emscripten_async_call
causes stack corruption.

Fixes: QTBUG-115959
Change-Id: Ibccccbf54f18df2d03f0c5e817c3a7102e96c9ed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Mikolaj Boc 2023-08-09 15:36:37 +02:00
parent 3adf81f09f
commit d0c92821af

View File

@ -420,7 +420,9 @@ void QEventDispatcherWasm::wakeUp()
// event loop. Make sure the thread is unblocked or make it // event loop. Make sure the thread is unblocked or make it
// process events. // process events.
bool wasBlocked = wakeEventDispatcherThread(); bool wasBlocked = wakeEventDispatcherThread();
if (!wasBlocked && isMainThreadEventDispatcher()) { // JSPI does not need a scheduled call to processPostedEvents, as the stack is not unwound
// at startup.
if (!qstdweb::haveJspi() && !wasBlocked && isMainThreadEventDispatcher()) {
{ {
LOCK_GUARD(m_mutex); LOCK_GUARD(m_mutex);
if (m_pendingProcessEvents) if (m_pendingProcessEvents)