From 8a48246ed1a93983668a25f5b9b0af0e745e3f04 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 6 Mar 2023 14:17:01 +0100 Subject: Everywhere: Stop using NonnullRefPtrVector This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector with Vector>. --- Userland/Libraries/LibCore/Object.cpp | 6 +++--- Userland/Libraries/LibCore/Object.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Userland/Libraries/LibCore') diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp index ccb93c4eb0..07012841e8 100644 --- a/Userland/Libraries/LibCore/Object.cpp +++ b/Userland/Libraries/LibCore/Object.cpp @@ -48,7 +48,7 @@ Object::~Object() // NOTE: We also unparent the children, so that they won't try to unparent // themselves in their own destructors. for (auto& child : children) - child.m_parent = nullptr; + child->m_parent = nullptr; all_objects().remove(*this); stop_timer(); @@ -103,7 +103,7 @@ void Object::insert_child_before(Object& new_child, Object& before_child) void Object::remove_child(Object& object) { for (size_t i = 0; i < m_children.size(); ++i) { - if (m_children.ptr_at(i).ptr() == &object) { + if (m_children[i] == &object) { // NOTE: We protect the child so it survives the handling of ChildRemoved. NonnullRefPtr protector = object; object.m_parent = nullptr; @@ -119,7 +119,7 @@ void Object::remove_child(Object& object) void Object::remove_all_children() { while (!m_children.is_empty()) - m_children.first().remove_from_parent(); + m_children.first()->remove_from_parent(); } void Object::timer_event(Core::TimerEvent&) diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index f33c4d2239..90bbeb857c 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -112,14 +112,14 @@ public: DeprecatedString const& name() const { return m_name; } void set_name(DeprecatedString name) { m_name = move(name); } - NonnullRefPtrVector& children() { return m_children; } - NonnullRefPtrVector const& children() const { return m_children; } + Vector>& children() { return m_children; } + Vector> const& children() const { return m_children; } template void for_each_child(Callback callback) { for (auto& child : m_children) { - if (callback(child) == IterationDecision::Break) + if (callback(*child) == IterationDecision::Break) return; } } @@ -219,7 +219,7 @@ private: int m_timer_id { 0 }; unsigned m_inspector_count { 0 }; HashMap> m_properties; - NonnullRefPtrVector m_children; + Vector> m_children; Function m_event_filter; }; -- cgit v1.2.3