Skip to content

Commit

Permalink
Add MemWatchTreeNode::deleteChildren() method.
Browse files Browse the repository at this point in the history
Unlike `removeChildren()` (previously `clearAllChild()`), this method
does free the memory of the removed children.
  • Loading branch information
cristian64 committed May 17, 2024
1 parent 96264a5 commit 78b621e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/MemoryWatch/MemWatchTreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ MemWatchTreeNode::MemWatchTreeNode(MemWatchEntry* const entry, MemWatchTreeNode*

MemWatchTreeNode::~MemWatchTreeNode()
{
if (hasChildren())
qDeleteAll(m_children);
deleteChildren();
m_parent = nullptr;
delete m_entry;
m_entry = nullptr;
}

bool MemWatchTreeNode::isGroup() const
Expand Down Expand Up @@ -117,6 +117,12 @@ void MemWatchTreeNode::removeChildren()
m_children.clear();
}

void MemWatchTreeNode::deleteChildren()
{
qDeleteAll(m_children);
m_children.clear();
}

void MemWatchTreeNode::readFromJson(const QJsonObject& json, MemWatchTreeNode* parent)
{
m_parent = parent;
Expand Down
1 change: 1 addition & 0 deletions Source/MemoryWatch/MemWatchTreeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MemWatchTreeNode
void insertChild(int row, MemWatchTreeNode* node);
void removeChild(int row);
void removeChildren();
void deleteChildren();

void readFromJson(const QJsonObject& json, MemWatchTreeNode* parent = nullptr);
void writeToJson(QJsonObject& json) const;
Expand Down

0 comments on commit 78b621e

Please sign in to comment.