Make sure timer is fini'd before clock (#553)
* Make sure timer is fini'd before clock
This commit is contained in:
parent
8c6f38a0fa
commit
b1af28047c
1 changed files with 3 additions and 1 deletions
|
@ -27,7 +27,7 @@ TimerBase::TimerBase(rclcpp::Clock::SharedPtr clock, std::chrono::nanoseconds pe
|
||||||
clock_ = clock;
|
clock_ = clock;
|
||||||
|
|
||||||
timer_handle_ = std::shared_ptr<rcl_timer_t>(
|
timer_handle_ = std::shared_ptr<rcl_timer_t>(
|
||||||
new rcl_timer_t, [ = ](rcl_timer_t * timer)
|
new rcl_timer_t, [ = ](rcl_timer_t * timer) mutable
|
||||||
{
|
{
|
||||||
if (rcl_timer_fini(timer) != RCL_RET_OK) {
|
if (rcl_timer_fini(timer) != RCL_RET_OK) {
|
||||||
RCUTILS_LOG_ERROR_NAMED(
|
RCUTILS_LOG_ERROR_NAMED(
|
||||||
|
@ -36,6 +36,8 @@ TimerBase::TimerBase(rclcpp::Clock::SharedPtr clock, std::chrono::nanoseconds pe
|
||||||
rcl_reset_error();
|
rcl_reset_error();
|
||||||
}
|
}
|
||||||
delete timer;
|
delete timer;
|
||||||
|
// Captured shared pointer by copy, reset to make sure timer is finalized before clock
|
||||||
|
clock.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
*timer_handle_.get() = rcl_get_zero_initialized_timer();
|
*timer_handle_.get() = rcl_get_zero_initialized_timer();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue