LibCore: Add CObject::remove_from_parent()

This is a convenient shorthand for:

    if (object.parent())
        object.parent()->remove_child(object);
This commit is contained in:
Andreas Kling 2019-09-22 00:41:01 +02:00
commit f614081b83
Notes: sideshowbarker 2024-07-19 12:00:43 +09:00

View file

@ -85,6 +85,12 @@ public:
void dispatch_event(CEvent&, CObject* stay_within = nullptr);
void remove_from_parent()
{
if (m_parent)
m_parent->remove_child(*this);
}
protected:
explicit CObject(CObject* parent = nullptr, bool is_widget = false);