From c14f46e6f3798785e300a73975bfbd4492360e9a Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Thu, 11 Jun 2020 17:17:39 -0300 Subject: [PATCH] Check if context is valid when looping in spin_some (#1167) Signed-off-by: Ivan Santiago Paunovic --- rclcpp/src/rclcpp/executor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 83a8baf5bd..0c83e0deba 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -234,7 +234,7 @@ Executor::spin_some(std::chrono::nanoseconds max_duration) RCLCPP_SCOPE_EXIT(this->spinning.store(false); ); // non-blocking call to pre-load all available work wait_for_work(std::chrono::milliseconds::zero()); - while (spinning.load() && max_duration_not_elapsed()) { + while (rclcpp::ok(context_) && spinning.load() && max_duration_not_elapsed()) { AnyExecutable any_exec; if (get_next_ready_executable(any_exec)) { execute_any_executable(any_exec);