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.

Pick-to: 6.5 6.6
Fixes: QTBUG-112893
Change-Id: Iba7d87cf1c08cd302884782cb135d758afeb9e4b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Morten Sørvig 2023-06-28 13:53:24 +02:00 committed by Jukka Jokiniva
parent e84dc809e2
commit 9c9aca3b43

View File

@ -255,13 +255,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();
@ -269,23 +266,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)