Skip to content

Commit

Permalink
remove potential crash when an unfinished tree throws an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed May 2, 2021
1 parent 33c29e5 commit 8d3de63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/behavior_tree.cpp
Expand Up @@ -56,7 +56,9 @@ void applyRecursiveVisitor(TreeNode* node, const std::function<void(TreeNode*)>&
}
else if (auto decorator = dynamic_cast<BT::DecoratorNode*>(node))
{
applyRecursiveVisitor(decorator->child(), visitor);
if( decorator->child() ){
applyRecursiveVisitor(decorator->child(), visitor);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/decorator_node.cpp
Expand Up @@ -48,6 +48,9 @@ TreeNode* DecoratorNode::child()

void DecoratorNode::haltChild()
{
if( !child_node_ ){
return;
}
if (child_node_->status() == NodeStatus::RUNNING)
{
child_node_->halt();
Expand Down

0 comments on commit 8d3de63

Please sign in to comment.