Skip to content

Crash fixed #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion include/behaviortree_cpp/xml_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,23 @@ struct Tree
{
TreeNode* root_node;
std::vector<TreeNode::Ptr> nodes;

Tree() : root_node(nullptr)
{

}

Tree(TreeNode* root_node, std::vector<TreeNode::Ptr> nodes)
: root_node(root_node), nodes(nodes)
{

}

~Tree()
{
haltAllActions(root_node);
if (root_node) {
haltAllActions(root_node);
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ Tree buildTreeFromText(const BehaviorTreeFactory& factory, const std::string& te
std::vector<TreeNode::Ptr> nodes;
auto root = parser.instantiateTree(nodes);
assignBlackboardToEntireTree(root.get(), blackboard);
return {root.get(), nodes};
return Tree(root.get(), nodes);
}

Tree buildTreeFromFile(const BehaviorTreeFactory& factory, const std::string& filename,
Expand All @@ -555,6 +555,6 @@ Tree buildTreeFromFile(const BehaviorTreeFactory& factory, const std::string& fi
std::vector<TreeNode::Ptr> nodes;
auto root = parser.instantiateTree(nodes);
assignBlackboardToEntireTree(root.get(), blackboard);
return {root.get(), nodes};
return Tree(root.get(), nodes);
}
}