diff options
author | Linus Groh <mail@linusgroh.de> | 2020-12-27 17:14:44 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-27 18:36:43 +0100 |
commit | e955c024b2d23a5b0d0e7befaa56056041f57e00 (patch) | |
tree | d6a55651146706ab477f83241db551ec5b8a7ca4 /Libraries/LibCore | |
parent | ddaedbca8789eb17c900981d91da1afe9f46a10b (diff) | |
download | serenity-e955c024b2d23a5b0d0e7befaa56056041f57e00.zip |
LibCore: Add Object::remove_all_children()
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r-- | Libraries/LibCore/Object.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibCore/Object.h | 1 |
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); |