1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:05:08 +00:00

CObject: Put all CObjects on a global IntrusiveList for introspection

This will allow us to easily traverse the entire CObject graph.
This commit is contained in:
Andreas Kling 2019-08-17 11:26:19 +02:00
parent e3f3c980bf
commit 2fa2d72761
2 changed files with 14 additions and 1 deletions

View file

@ -5,16 +5,24 @@
#include <LibCore/CObject.h>
#include <stdio.h>
IntrusiveList<CObject, &CObject::m_all_objects_list_node>& CObject::all_objects()
{
static IntrusiveList<CObject, &CObject::m_all_objects_list_node> objects;
return objects;
}
CObject::CObject(CObject* parent, bool is_widget)
: m_parent(parent)
, m_widget(is_widget)
{
all_objects().append(*this);
if (m_parent)
m_parent->add_child(*this);
}
CObject::~CObject()
{
all_objects().remove(*this);
stop_timer();
if (m_parent)
m_parent->remove_child(*this);