From 94f0c34dfe51e4f14e4fb1d59117c5f08f3980ec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 16 Oct 2022 15:19:13 +0200 Subject: [PATCH] LibWeb: Remove unnecessary WeakPtr in queue_microtask_impl() Capturing a WeakPtr to a GC-allocated object in a JS::SafeFunction is basically pointless, since the SafeFunction mechanism will then keep the object alive anyway. --- Userland/Libraries/LibWeb/HTML/Window.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 5173b686c4c..8dad5e1d6a0 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -488,15 +488,11 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers void Window::queue_microtask_impl(WebIDL::CallbackType& callback) { // The queueMicrotask(callback) method must queue a microtask to invoke callback, - HTML::queue_a_microtask(&associated_document(), [weak_window = make_weak_ptr(), &callback]() mutable { - JS::GCPtr window = weak_window.ptr(); - if (!window) - return; - + HTML::queue_a_microtask(&associated_document(), [this, &callback]() mutable { auto result = WebIDL::invoke_callback(callback, {}); // and if callback throws an exception, report the exception. if (result.is_error()) - HTML::report_exception(result, window->realm()); + HTML::report_exception(result, realm()); }); }