diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index de3d87e0d3..5fcd74bbd7 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -213,16 +213,16 @@ void CTreeItem::moveUnder(CTreeItem *newParent) { } void CTreeItem::destroyAll() { - destroyOthers(); + destroyChildren(); detach(); delete this; } -int CTreeItem::destroyOthers() { +int CTreeItem::destroyChildren() { if (!_firstChild) return 0; - CTreeItem *item = this, *child, *nextSibling; + CTreeItem *item = _firstChild, *child, *nextSibling; int total = 0; do { @@ -230,9 +230,9 @@ int CTreeItem::destroyOthers() { nextSibling = item->_nextSibling; if (child) - total += child->destroyOthers(); - child->detach(); - delete child; + total += item->destroyChildren(); + item->detach(); + delete item; ++total; } while ((item = nextSibling) != nullptr); diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index 49a3fa7a65..46d7996f0f 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -233,9 +233,10 @@ public: void destroyAll(); /** - * Destroys all tree items around the given one + * Destroys all child tree items under this one. + * @returns Total number of tree items recursively removed */ - int destroyOthers(); + int destroyChildren(); /** * Detach the tree item from any other associated tree items |