TITANIC: Fix destroying previous game project when loading savegame

This commit is contained in:
Paul Gilbert 2016-07-20 19:03:30 -04:00
parent 1102203396
commit 543434aa78
2 changed files with 9 additions and 8 deletions

View File

@ -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);

View File

@ -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