Skip to content

Commit 3540b4a

Browse files
committed
Fix dangling‐capture in TestNodeConfig
1 parent 5f3f675 commit 3540b4a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/behaviortree_cpp/actions/test_node.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ struct TestNodeConfig
3737
/// if async_delay > 0, this action become asynchronous and wait this amount of time
3838
std::chrono::milliseconds async_delay = std::chrono::milliseconds(0);
3939

40-
/// Function invoked when the action is completed. By default just return [return_status]
41-
/// Override it to intorduce more comple cases
42-
std::function<NodeStatus(void)> complete_func = [this]() { return return_status; };
40+
/// Function invoked when the action is completed.
41+
/// If not specified, the node will return [return_status]
42+
std::function<NodeStatus(void)> complete_func;
4343
};
4444

4545
/**

src/actions/test_node.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ BT::NodeStatus BT::TestNode::onCompleted()
6868
{
6969
Ast::Environment env = { config().blackboard, config().enums };
7070

71-
auto status = _test_config.complete_func();
71+
auto status = (_test_config.complete_func) ? _test_config.complete_func() :
72+
_test_config.return_status;
7273
if(status == NodeStatus::SUCCESS && _success_executor)
7374
{
7475
_success_executor(env);

0 commit comments

Comments
 (0)