summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-12-27 17:14:44 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-27 18:36:43 +0100
commite955c024b2d23a5b0d0e7befaa56056041f57e00 (patch)
treed6a55651146706ab477f83241db551ec5b8a7ca4 /Libraries/LibCore
parentddaedbca8789eb17c900981d91da1afe9f46a10b (diff)
downloadserenity-e955c024b2d23a5b0d0e7befaa56056041f57e00.zip
LibCore: Add Object::remove_all_children()
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/Object.cpp6
-rw-r--r--Libraries/LibCore/Object.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibCore/Object.cpp b/Libraries/LibCore/Object.cpp
index df2359e001..7db8548073 100644
--- a/Libraries/LibCore/Object.cpp
+++ b/Libraries/LibCore/Object.cpp
@@ -130,6 +130,12 @@ void Object::remove_child(Object& object)
ASSERT_NOT_REACHED();
}
+void Object::remove_all_children()
+{
+ while (!m_children.is_empty())
+ m_children.first().remove_from_parent();
+}
+
void Object::timer_event(Core::TimerEvent&)
{
}
diff --git a/Libraries/LibCore/Object.h b/Libraries/LibCore/Object.h
index ce3355e88c..1bed1110b4 100644
--- a/Libraries/LibCore/Object.h
+++ b/Libraries/LibCore/Object.h
@@ -105,6 +105,7 @@ public:
void add_child(Object&);
void insert_child_before(Object& new_child, Object& before_child);
void remove_child(Object&);
+ void remove_all_children();
void dump_tree(int indent = 0);