1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

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>>.
This commit is contained in:
Andreas Kling 2023-03-06 14:17:01 +01:00
parent 104be6c8ac
commit 8a48246ed1
168 changed files with 1280 additions and 1280 deletions

View file

@ -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&)

View file

@ -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;
};