Ladybird: Don't burn 100% CPU in EventLoopPluginQt::spin_until()

There's no point in busy-waiting for the condition to come true.
By passing the `WaitForMoreEvents` flag to `processEvents()`, we allow
Qt to block until it has something for us to react to.

This was extremely noticeable when waiting for large resources to
finish loading.
This commit is contained in:
Andreas Kling 2022-11-07 11:06:29 +01:00 committed by Andrew Kaster
parent bc6a6190d8
commit ef553a4b76
Notes: sideshowbarker 2024-07-17 02:40:26 +09:00

View file

@ -21,7 +21,7 @@ EventLoopPluginQt::~EventLoopPluginQt() = default;
void EventLoopPluginQt::spin_until(Function<bool()> goal_condition)
{
while (!goal_condition())
QCoreApplication::processEvents();
QCoreApplication::processEvents(QEventLoop::ProcessEventsFlag::AllEvents | QEventLoop::ProcessEventsFlag::WaitForMoreEvents);
}
void EventLoopPluginQt::deferred_invoke(Function<void()> function)