mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
Shell: Block on the existing event loop instead of pushing a new one
This patch makes `Shell::block_on_job()` pump the event loop while the job it's waiting for hasn't finished. As this no longer pushes new event loops, it has the effect of flattening the stack as well. Fixes #4976.
This commit is contained in:
parent
2bd77bc93b
commit
be94a4ffa6
Notes:
sideshowbarker
2024-07-18 22:56:59 +09:00
Author: https://github.com/alimpfard
Commit: be94a4ffa6
Pull-request: https://github.com/SerenityOS/serenity/pull/4981
Issue: https://github.com/SerenityOS/serenity/issues/4976
Reviewed-by: https://github.com/awesomekling
1 changed files with 4 additions and 3 deletions
|
@ -1079,17 +1079,18 @@ void Shell::block_on_job(RefPtr<Job> job)
|
|||
}
|
||||
} };
|
||||
|
||||
Core::EventLoop loop;
|
||||
bool job_exited { false };
|
||||
job->on_exit = [&, old_exit = move(job->on_exit)](auto job) {
|
||||
if (old_exit)
|
||||
old_exit(job);
|
||||
loop.quit(0);
|
||||
job_exited = true;
|
||||
};
|
||||
|
||||
if (job->exited())
|
||||
return;
|
||||
|
||||
loop.exec();
|
||||
while (!job_exited)
|
||||
Core::EventLoop::current().pump();
|
||||
|
||||
// If the job is part of a pipeline, wait for the rest of the members too.
|
||||
if (auto command = job->command_ptr())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue