File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,16 @@ class EventHandler : public EventHandlerBase
260260 }
261261 }
262262
263+ ~EventHandler ()
264+ {
265+ // Since the rmw event listener holds a reference to the
266+ // "on ready" callback, we need to clear it on destruction of this class.
267+ // This clearing is not needed for other rclcpp entities like pub/subs, since
268+ // they do own the underlying rmw entities, which are destroyed
269+ // on their rclcpp destructors, thus no risk of dangling pointers.
270+ clear_on_ready_callback ();
271+ }
272+
263273 // / Take data so that the callback cannot be scheduled again
264274 std::shared_ptr<void >
265275 take_data () override
Original file line number Diff line number Diff line change @@ -39,13 +39,6 @@ UnsupportedEventTypeException::UnsupportedEventTypeException(
3939
4040EventHandlerBase::~EventHandlerBase ()
4141{
42- // Since the rmw event listener holds a reference to
43- // this callback, we need to clear it on destruction of this class.
44- // This clearing is not needed for other rclcpp entities like pub/subs, since
45- // they do own the underlying rmw entities, which are destroyed
46- // on their rclcpp destructors, thus no risk of dangling pointers.
47- clear_on_ready_callback ();
48-
4942 if (rcl_event_fini (&event_handle_) != RCL_RET_OK) {
5043 RCUTILS_LOG_ERROR_NAMED (
5144 " rclcpp" ,
You can’t perform that action at this time.
0 commit comments