From 238e90cd58433ec79e82325d06fb75d9038b9607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Mon, 8 Aug 2022 20:49:11 +0200 Subject: [PATCH] wasm: remove dead qt_asyncify_yield() code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call to this function was behind a broken #define and was never enabled. It also does not work, so remove it. This means that calling processEvents() in a loop (as opposed to calling exec()) most likely does not work either, which is something we want to revisit. Pick-to: 6.4 Change-Id: I90802a69d3a48e7f2b5d0b657d89452c09d9571a Reviewed-by: Tor Arne Vestbø --- src/corelib/kernel/qeventdispatcher_wasm.cpp | 29 -------------------- src/corelib/kernel/qeventdispatcher_wasm_p.h | 1 - 2 files changed, 30 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index c733f46c140..2363d5a79b7 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -76,17 +76,6 @@ bool qt_asyncify_resume() return true; } -// Yields control to the browser, so that it can process events. Must -// be called on the main thread. Returns false immediately if Qt has -// already suspended the main thread. Returns true after yielding. -bool qt_asyncify_yield() -{ - if (g_is_asyncify_suspended) - return false; - emscripten_sleep(0); - return true; -} - #endif // QT_HAVE_EMSCRIPTEN_ASYNCIFY Q_CONSTINIT QEventDispatcherWasm *QEventDispatcherWasm::g_mainThreadEventDispatcher = nullptr; @@ -198,9 +187,6 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags) handleApplicationExec(); } - if (!(flags & QEventLoop::ExcludeUserInputEvents)) - pollForNativeEvents(); - hasPendingEvents = qGlobalPostedEventsCount() > 0; if (!hasPendingEvents && (flags & QEventLoop::WaitForMoreEvents)) @@ -386,21 +372,6 @@ void QEventDispatcherWasm::handleDialogExec() // For the asyncify case we do nothing here and wait for events in wait() } -void QEventDispatcherWasm::pollForNativeEvents() -{ - // Secondary thread event dispatchers do not support native events - if (isSecondaryThreadEventDispatcher()) - return; - -#if HAVE_EMSCRIPTEN_ASYNCIFY - // Asyncify allows us to yield to the browser and have it process native events - - // but this will fail if we are recursing and are already in a yield. - bool didYield = qt_asyncify_yield(); - if (!didYield) - qWarning("QEventDispatcherWasm::processEvents() did not asyncify process native events"); -#endif -} - // Blocks/suspends the calling thread. This is possible in two cases: // - Caller is a secondary thread: block on m_moreEvents // - Caller is the main thread and asyncify is enabled: suspend using qt_asyncify_suspend() diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index a0cd182d821..b6de4187f4f 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -62,7 +62,6 @@ private: void handleApplicationExec(); void handleDialogExec(); - void pollForNativeEvents(); bool wait(int timeout = -1); bool wakeEventDispatcherThread(); static void callProcessEvents(void *eventDispatcher);