summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-11-07 11:06:29 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-25 07:58:58 -0700
commitef553a4b768cb6b5a5acd0305098a2111febede6 (patch)
tree7464a05b23e3938716c1ad9250d157b8ad801eba
parentbc6a6190d8a329959ea92417acabb5df3fa3c3e3 (diff)
downloadserenity-ef553a4b768cb6b5a5acd0305098a2111febede6.zip
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.
-rw-r--r--Ladybird/EventLoopPluginQt.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Ladybird/EventLoopPluginQt.cpp b/Ladybird/EventLoopPluginQt.cpp
index 8a531e015b..b1c58332b2 100644
--- a/Ladybird/EventLoopPluginQt.cpp
+++ b/Ladybird/EventLoopPluginQt.cpp
@@ -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)