mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibCore: Add Notifier::close
If a file descriptor is being closed, we need to permanently disable any Notifier and remove it from the event loop. This method removes the notifier and disables it so that the EventLoop does not use a invalid file descriptor.
This commit is contained in:
@@ -46,12 +46,22 @@ Notifier::~Notifier()
|
||||
|
||||
void Notifier::set_enabled(bool enabled)
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return;
|
||||
if (enabled)
|
||||
Core::EventLoop::register_notifier({}, *this);
|
||||
else
|
||||
Core::EventLoop::unregister_notifier({}, *this);
|
||||
}
|
||||
|
||||
void Notifier::close()
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return;
|
||||
set_enabled(false);
|
||||
m_fd = -1;
|
||||
}
|
||||
|
||||
void Notifier::event(Core::Event& event)
|
||||
{
|
||||
if (event.type() == Core::Event::NotifierRead && on_ready_to_read) {
|
||||
|
||||
Reference in New Issue
Block a user