From 58174d0ebe1b4513e313518b107420257ca1a0e6 Mon Sep 17 00:00:00 2001 From: Aditya Pande Date: Mon, 9 Aug 2021 12:08:01 -0700 Subject: [PATCH] cleanup, added nullptr check to node.cpp, lifecyclenode.cpp Signed-off-by: Aditya Pande --- rclcpp/include/rclcpp/node.hpp | 1 - rclcpp/include/rclcpp/node_interfaces/node_base.hpp | 2 -- rclcpp/src/rclcpp/node.cpp | 4 +++- rclcpp_lifecycle/src/lifecycle_node.cpp | 4 +++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rclcpp/include/rclcpp/node.hpp b/rclcpp/include/rclcpp/node.hpp index 1e19a95247..44119ee2fc 100644 --- a/rclcpp/include/rclcpp/node.hpp +++ b/rclcpp/include/rclcpp/node.hpp @@ -70,7 +70,6 @@ #include "rclcpp/timer.hpp" #include "rclcpp/visibility_control.hpp" - namespace rclcpp { diff --git a/rclcpp/include/rclcpp/node_interfaces/node_base.hpp b/rclcpp/include/rclcpp/node_interfaces/node_base.hpp index 39790c4292..1fac7c8b10 100644 --- a/rclcpp/include/rclcpp/node_interfaces/node_base.hpp +++ b/rclcpp/include/rclcpp/node_interfaces/node_base.hpp @@ -15,8 +15,6 @@ #ifndef RCLCPP__NODE_INTERFACES__NODE_BASE_HPP_ #define RCLCPP__NODE_INTERFACES__NODE_BASE_HPP_ -#include -#include #include #include #include diff --git a/rclcpp/src/rclcpp/node.cpp b/rclcpp/src/rclcpp/node.cpp index d8a5a8dbcb..acbb55e7ec 100644 --- a/rclcpp/src/rclcpp/node.cpp +++ b/rclcpp/src/rclcpp/node.cpp @@ -610,5 +610,7 @@ void Node::for_each_callback_group( const node_interfaces::NodeBaseInterface::CallbackGroupFunction & func) { auto node_base = std::dynamic_pointer_cast(node_base_); - node_base->for_each_callback_group(func); + if (!node_base) { + node_base->for_each_callback_group(func); + } } diff --git a/rclcpp_lifecycle/src/lifecycle_node.cpp b/rclcpp_lifecycle/src/lifecycle_node.cpp index 9d81a6db95..1b51b1fcb8 100644 --- a/rclcpp_lifecycle/src/lifecycle_node.cpp +++ b/rclcpp_lifecycle/src/lifecycle_node.cpp @@ -656,7 +656,9 @@ LifecycleNode::for_each_callback_group( const rclcpp::node_interfaces::NodeBaseInterface::CallbackGroupFunction & func) { auto node_base = std::dynamic_pointer_cast(node_base_); - node_base->for_each_callback_group(func); + if (!node_base) { + node_base->for_each_callback_group(func); + } } } // namespace rclcpp_lifecycle