Delete children Nodes in Node's destructor. Also delet the tree in NodeTree's destructor.

This commit is contained in:
Relintai 2022-01-08 14:11:08 +01:00
parent bd93a2a9ce
commit 10effc3971
2 changed files with 15 additions and 5 deletions

View File

@ -110,4 +110,9 @@ Node::Node() :
}
Node::~Node() {
for (int i = 0; i < _children.size(); ++i) {
delete _children[i];
}
_children.clear();
}

View File

@ -8,9 +8,9 @@ Node *NodeTree::get_root() {
}
void NodeTree::set_root(Node *root) {
if (_root_node) {
_root_node->set_tree(nullptr);
}
if (_root_node) {
_root_node->set_tree(nullptr);
}
_root_node = root;
@ -20,11 +20,16 @@ void NodeTree::set_root(Node *root) {
}
void NodeTree::send_update(float delta) {
//todo
// todo
}
NodeTree::NodeTree() : Object() {
NodeTree::NodeTree() :
Object() {
}
NodeTree::~NodeTree() {
if (_root_node) {
delete _root_node;
_root_node == nullptr;
}
}