mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +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:
parent
e3f3c980bf
commit
2fa2d72761
Notes:
sideshowbarker
2024-07-19 12:39:44 +09:00
Author: https://github.com/awesomekling
Commit: 2fa2d72761
2 changed files with 14 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue