diff --git a/Libraries/LibThread/BackgroundAction.h b/Libraries/LibThread/BackgroundAction.h index 9bc7224956aa0f..b7b5b0810c0d98 100644 --- a/Libraries/LibThread/BackgroundAction.h +++ b/Libraries/LibThread/BackgroundAction.h @@ -75,17 +75,17 @@ class BackgroundAction final : public Core::Object { LOCKER(all_actions().lock()); - this->ref(); all_actions().resource().enqueue([this] { m_result = m_action(); if (m_on_complete) { Core::EventLoop::current().post_event(*this, make([this](auto&) { m_on_complete(m_result.release_value()); - this->unref(); + this->remove_from_parent(); })); Core::EventLoop::wake(); - } else - this->unref(); + } else { + this->remove_from_parent(); + } }); }