summaryrefslogtreecommitdiff
path: root/jni/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'jni/node.cpp')
-rw-r--r--jni/node.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/jni/node.cpp b/jni/node.cpp
index 618777442..e17a9e88a 100644
--- a/jni/node.cpp
+++ b/jni/node.cpp
@@ -97,13 +97,15 @@ void node::DeleteTree(node* tree) {
std::lock_guard<std::recursive_mutex> guard(*tree->lock_);
if (tree) {
- for (node* child : tree->children_) {
+ // Make a copy of the list of children because calling Delete tree
+ // will modify the list of children, which will cause issues while
+ // iterating over them.
+ std::vector<node*> children(tree->children_.begin(), tree->children_.end());
+ for (node* child : children) {
DeleteTree(child);
}
- tree->children_.clear();
- LOG(DEBUG) << "DELETE node " << tree->GetName();
- tree->RemoveFromParent();
+ CHECK(tree->children_.empty());
delete tree;
}
}