Skip to content

Commit

Permalink
Rename MemWatchTreeNode::clearAllChild() to `MemWatchTreeNode::remo…
Browse files Browse the repository at this point in the history
…veChildren()`.

This method did not (and still does not) delete the memory of the
removed children; it merely removes the children from the parent's child
list. This behavior matches the `removeChild(int)` method, which does
not free the memory of the removed child either.
  • Loading branch information
cristian64 committed May 17, 2024
1 parent ae7c268 commit 96264a5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/GUI/MemWatcher/MemWatchModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void MemWatchModel::editEntry(MemWatchEntry* entry, const QModelIndex& index)

void MemWatchModel::clearRoot()
{
m_rootNode->clearAllChild();
m_rootNode->removeChildren();
emit layoutChanged();
}

Expand Down
6 changes: 3 additions & 3 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ void MemWatchWidget::copySelectedWatchesToClipBoard()
}
rootNodeCopy.writeToJson(jsonNode);

// Clear borrowed children before going out of scope.
rootNodeCopy.clearAllChild();
// Remove borrowed children before going out of scope.
rootNodeCopy.removeChildren();
for (auto& [childNode, parentNode] : parentMap)
{
childNode->setParent(parentNode);
Expand All @@ -353,7 +353,7 @@ void MemWatchWidget::pasteWatchFromClipBoard(const QModelIndex& referenceIndex)
}

const QVector<MemWatchTreeNode*> children{copiedRootNode.getChildren()};
copiedRootNode.clearAllChild();
copiedRootNode.removeChildren();

std::vector<MemWatchTreeNode*> childrenVec(children.constBegin(), children.constEnd());
m_watchModel->addNodes(childrenVec, referenceIndex);
Expand Down
2 changes: 1 addition & 1 deletion Source/MemoryWatch/MemWatchTreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void MemWatchTreeNode::removeChild(const int row)
m_children.remove(row);
}

void MemWatchTreeNode::clearAllChild()
void MemWatchTreeNode::removeChildren()
{
m_children.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/MemoryWatch/MemWatchTreeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MemWatchTreeNode
void appendChild(MemWatchTreeNode* node);
void insertChild(int row, MemWatchTreeNode* node);
void removeChild(int row);
void clearAllChild();
void removeChildren();

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

0 comments on commit 96264a5

Please sign in to comment.