mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
LibCore+LibWebView: Restore was_exit_requested to EventLoop
This method was removed in e015a43b51
However, it was not exactly *unused* as the commit message would say.
This method was the only thing that allowed spin_until to exit when
the event loop was cancelled. This happens normally when IPC connections
are closed, but also when the process is killed.
The logic to properly handle process exit from event loop spins needs to
actually notify the caller that their goal condition was not met though.
That will be handled in a later commit.
This commit is contained in:
parent
0cd5e99066
commit
b50d03f42e
Notes:
github-actions[bot]
2025-04-30 15:13:48 +00:00
Author: https://github.com/ADKaster
Commit: b50d03f42e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4527
Reviewed-by: https://github.com/trflynn89 ✅
9 changed files with 25 additions and 1 deletions
|
@ -65,6 +65,11 @@ void EventLoop::quit(int code)
|
|||
m_impl->quit(code);
|
||||
}
|
||||
|
||||
bool EventLoop::was_exit_requested()
|
||||
{
|
||||
return m_impl->was_exit_requested();
|
||||
}
|
||||
|
||||
struct EventLoopPusher {
|
||||
public:
|
||||
EventLoopPusher(EventLoop& event_loop)
|
||||
|
|
|
@ -78,6 +78,8 @@ public:
|
|||
|
||||
void quit(int);
|
||||
|
||||
bool was_exit_requested();
|
||||
|
||||
// The registration functions act upon the current loop of the current thread.
|
||||
static intptr_t register_timer(EventReceiver&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible);
|
||||
static void unregister_timer(intptr_t timer_id);
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
virtual size_t pump(PumpMode) = 0;
|
||||
virtual void quit(int) = 0;
|
||||
virtual void wake() = 0;
|
||||
virtual bool was_exit_requested() const = 0;
|
||||
|
||||
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) = 0;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
virtual int exec() override;
|
||||
virtual size_t pump(PumpMode) override;
|
||||
virtual void quit(int) override;
|
||||
virtual bool was_exit_requested() const override { return m_exit_requested; }
|
||||
|
||||
virtual void wake() override;
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ public:
|
|||
virtual int exec() override;
|
||||
virtual size_t pump(PumpMode) override;
|
||||
virtual void quit(int) override;
|
||||
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override { return m_exit_requested; }
|
||||
|
||||
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) override;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
virtual size_t pump(PumpMode) override;
|
||||
virtual void quit(int) override;
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override;
|
||||
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -404,6 +404,11 @@ void EventLoopImplementationMacOS::wake()
|
|||
CFRunLoopWakeUp(CFRunLoopGetCurrent());
|
||||
}
|
||||
|
||||
bool EventLoopImplementationMacOS::was_exit_requested() const
|
||||
{
|
||||
return ![NSApp isRunning];
|
||||
}
|
||||
|
||||
void EventLoopImplementationMacOS::post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
|
|
|
@ -222,6 +222,13 @@ void EventLoopImplementationQt::wake()
|
|||
m_event_loop->wakeUp();
|
||||
}
|
||||
|
||||
bool EventLoopImplementationQt::was_exit_requested() const
|
||||
{
|
||||
if (is_main_loop())
|
||||
return QCoreApplication::closingDown();
|
||||
return !m_event_loop->isRunning();
|
||||
}
|
||||
|
||||
void EventLoopImplementationQt::post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
virtual size_t pump(PumpMode) override;
|
||||
virtual void quit(int) override;
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override;
|
||||
|
||||
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;
|
||||
|
||||
void set_main_loop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue