diff options
author | Andreas Kling <kling@serenityos.org> | 2023-03-06 14:17:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-06 23:46:35 +0100 |
commit | 8a48246ed1a93983668a25f5b9b0af0e745e3f04 (patch) | |
tree | dd98425d119f79e0160bf19951f96a4a30276cbb /Userland/Libraries/LibCore | |
parent | 104be6c8ace8d56f66a89b570cdd615e74d22aa8 (diff) | |
download | serenity-8a48246ed1a93983668a25f5b9b0af0e745e3f04.zip |
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<T> with Vector<NNRP<T>>.
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r-- | Userland/Libraries/LibCore/Object.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/Object.h | 8 |
2 files changed, 7 insertions, 7 deletions
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<Object> 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<Object>& children() { return m_children; } - NonnullRefPtrVector<Object> const& children() const { return m_children; } + Vector<NonnullRefPtr<Object>>& children() { return m_children; } + Vector<NonnullRefPtr<Object>> const& children() const { return m_children; } template<typename Callback> 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<DeprecatedString, NonnullOwnPtr<Property>> m_properties; - NonnullRefPtrVector<Object> m_children; + Vector<NonnullRefPtr<Object>> m_children; Function<bool(Core::Event&)> m_event_filter; }; |