Skip to content

Commit fb97302

Browse files
BriceRenaudeauSteveMacenski
authored andcommitted
Fix SimpleActionServer nullprt callback (#4025)
* add check before calling completion_callback_ * Fix lint
1 parent 8831248 commit fb97302

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nav2_util/include/nav2_util/simple_action_server.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class SimpleActionServer
244244
node_logging_interface_->get_logger(),
245245
"Action server failed while executing action callback: \"%s\"", ex.what());
246246
terminate_all();
247-
completion_callback_();
247+
if (completion_callback_) {completion_callback_();}
248248
return;
249249
}
250250

@@ -254,14 +254,14 @@ class SimpleActionServer
254254
if (stop_execution_) {
255255
warn_msg("Stopping the thread per request.");
256256
terminate_all();
257-
completion_callback_();
257+
if (completion_callback_) {completion_callback_();}
258258
break;
259259
}
260260

261261
if (is_active(current_handle_)) {
262262
warn_msg("Current goal was not completed successfully.");
263263
terminate(current_handle_);
264-
completion_callback_();
264+
if (completion_callback_) {completion_callback_();}
265265
}
266266

267267
if (is_active(pending_handle_)) {
@@ -314,7 +314,7 @@ class SimpleActionServer
314314
info_msg("Waiting for async process to finish.");
315315
if (steady_clock::now() - start_time >= server_timeout_) {
316316
terminate_all();
317-
completion_callback_();
317+
if (completion_callback_) {completion_callback_();}
318318
throw std::runtime_error("Action callback is still running and missed deadline to stop");
319319
}
320320
}

0 commit comments

Comments
 (0)