File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
include/behaviortree_cpp/decorators Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,15 @@ class TimeoutNode : public DecoratorNode
77
77
if (msec_ > 0 )
78
78
{
79
79
timer_id_ = timer_.add (std::chrono::milliseconds (msec_), [this ](bool aborted) {
80
+ // Return immediately if the timer was aborted.
81
+ // This function could be invoked during destruction of this object and
82
+ // we don't want to access member variables if not needed.
83
+ if (aborted)
84
+ {
85
+ return ;
86
+ }
80
87
std::unique_lock<std::mutex> lk (timeout_mutex_);
81
- if (!aborted && child ()->status () == NodeStatus::RUNNING)
88
+ if (child ()->status () == NodeStatus::RUNNING)
82
89
{
83
90
child_halted_ = true ;
84
91
haltChild ();
Original file line number Diff line number Diff line change @@ -225,7 +225,9 @@ class TimerQueue
225
225
226
226
lk.unlock ();
227
227
if (item.handler )
228
+ {
228
229
item.handler (item.id == 0 );
230
+ }
229
231
lk.lock ();
230
232
}
231
233
}
You can’t perform that action at this time.
0 commit comments