wasm: don't use on qGlobalPostedEventsCount()

There is no guarantee that it will return 0 after one call
to sendPostedEvents(), since more events may have been
posted during that call. This can in turn cause infinite
looping since the wait() isn't called.

Move sendPostedEvents to the top of processEvents()
to make sure we send events before waiting, in line
with the implementation for the other event dispatchers.

Fixes: QTBUG-112893
Change-Id: Iba7d87cf1c08cd302884782cb135d758afeb9e4b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 9c9aca3b4393a1f1c8169c7b811e46ec5de25df9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2023-06-28 13:53:24 +02:00 committed by Qt Cherry-pick Bot
parent 390b2b773e
commit ee72e23897

View File

@ -212,13 +212,10 @@ bool QEventDispatcherWasm::isValidEventDispatcherPointer(QEventDispatcherWasm *e
bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
{
qCDebug(lcEventDispatcher) << "QEventDispatcherWasm::processEvents flags" << flags;
emit awake();
bool hasPendingEvents = qGlobalPostedEventsCount() > 0;
qCDebug(lcEventDispatcher) << "QEventDispatcherWasm::processEvents flags" << flags
<< "pending events" << hasPendingEvents;
if (isMainThreadEventDispatcher()) {
if (flags & QEventLoop::DialogExec)
handleDialogExec();
@ -226,23 +223,23 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
handleApplicationExec();
}
if (!hasPendingEvents && (flags & QEventLoop::WaitForMoreEvents))
wait();
QCoreApplication::sendPostedEvents();
processWindowSystemEvents(flags);
if (m_interrupted) {
m_interrupted = false;
return false;
}
if (flags & QEventLoop::WaitForMoreEvents)
wait();
if (m_processTimers) {
m_processTimers = false;
processTimers();
}
QCoreApplication::sendPostedEvents();
processWindowSystemEvents(flags);
return qGlobalPostedEventsCount() > 0;
return false;
}
void QEventDispatcherWasm::processWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)