diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index 210ffc9714..ded5a0d0c7 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -168,7 +168,7 @@ struct Formatter> : Formatter { }; template -WeakPtr try_make_weak_ptr(const T* ptr) +WeakPtr make_weak_ptr_if_nonnull(const T* ptr) { if (ptr) { return ptr->template make_weak_ptr(); diff --git a/Kernel/Library/ThreadSafeWeakPtr.h b/Kernel/Library/ThreadSafeWeakPtr.h index 3095e10260..aec6e10970 100644 --- a/Kernel/Library/ThreadSafeWeakPtr.h +++ b/Kernel/Library/ThreadSafeWeakPtr.h @@ -229,7 +229,7 @@ struct Formatter> : Formatter { }; template -WeakPtr try_make_weak_ptr(const T* ptr) +WeakPtr make_weak_ptr_if_nonnull(const T* ptr) { if (ptr) { return ptr->template make_weak_ptr(); diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index c7123dfc7b..6984e0fe81 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -404,7 +404,7 @@ static ErrorOr load_elf_object(NonnullOwnPtr n load_base_address, elf_image.entry().offset(load_offset).get(), executable_size, - AK::try_make_weak_ptr(master_tls_region), + AK::make_weak_ptr_if_nonnull(master_tls_region), master_tls_size, master_tls_alignment, stack_region->make_weak_ptr() diff --git a/Userland/Libraries/LibCore/Event.cpp b/Userland/Libraries/LibCore/Event.cpp index bb98edd444..117936043a 100644 --- a/Userland/Libraries/LibCore/Event.cpp +++ b/Userland/Libraries/LibCore/Event.cpp @@ -13,7 +13,7 @@ namespace Core { ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child) : Core::Event(type) , m_child(child.make_weak_ptr()) - , m_insertion_before_child(AK::try_make_weak_ptr(insertion_before_child)) + , m_insertion_before_child(AK::make_weak_ptr_if_nonnull(insertion_before_child)) { } diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 5095fe0664..8191798993 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -214,7 +214,7 @@ void Action::set_checked(bool checked) void Action::set_group(Badge, ActionGroup* group) { - m_action_group = AK::try_make_weak_ptr(group); + m_action_group = AK::make_weak_ptr_if_nonnull(group); } void Action::set_icon(const Gfx::Bitmap* icon) diff --git a/Userland/Libraries/LibGUI/CommonActions.cpp b/Userland/Libraries/LibGUI/CommonActions.cpp index 8fbd5aaa1d..27c3e8cfb8 100644 --- a/Userland/Libraries/LibGUI/CommonActions.cpp +++ b/Userland/Libraries/LibGUI/CommonActions.cpp @@ -17,7 +17,7 @@ namespace CommonActions { NonnullRefPtr make_about_action(const String& app_name, const Icon& app_icon, Window* parent) { - auto weak_parent = AK::try_make_weak_ptr(parent); + auto weak_parent = AK::make_weak_ptr_if_nonnull(parent); auto action = Action::create(String::formatted("&About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) { AboutDialog::show(app_name, app_icon.bitmap_for_size(32), weak_parent.ptr()); });