diff options
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_wasm.cpp')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_wasm.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index 15ada58aad..b499cf91fe 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -480,14 +480,22 @@ void QEventDispatcherWasm::updateNativeTimer() return ts.tv_sec * 1000 + ts.tv_nsec / (1000 * 1000); }; timespec toWait; - m_timerInfo->timerWait(toWait); + bool hasTimer = m_timerInfo->timerWait(toWait); uint64_t currentTime = timespecToNanosec(m_timerInfo->currentTime); uint64_t toWaitDuration = timespecToNanosec(toWait); uint64_t newTargetTime = currentTime + toWaitDuration; - auto maintainNativeTimer = [this, toWaitDuration, newTargetTime]() { + auto maintainNativeTimer = [this, hasTimer, toWaitDuration, newTargetTime]() { Q_ASSERT(emscripten_is_main_runtime_thread()); + if (!hasTimer) { + if (m_timerId > 0) { + emscripten_clear_timeout(m_timerId); + m_timerId = 0; + } + return; + } + if (m_timerTargetTime != 0 && newTargetTime >= m_timerTargetTime) return; // existing timer is good |