mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
LibWeb: Sever parent/child connections in ~TreeNode()
Also make sure to unref the children if there are any. Without this it was very easy to leak TreeNodes.
This commit is contained in:
parent
41e5a0fe02
commit
c70e0a4f29
1 changed files with 11 additions and 0 deletions
|
@ -299,6 +299,17 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
~TreeNode()
|
||||
{
|
||||
VERIFY(!m_parent);
|
||||
T* next_child = nullptr;
|
||||
for (auto* child = m_first_child; child; child = next_child) {
|
||||
next_child = child->m_next_sibling;
|
||||
child->m_parent = nullptr;
|
||||
child->unref();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TreeNode() { }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue