From 6666f423267087b1f5f4bef3df9abcc8366dc2cc Mon Sep 17 00:00:00 2001 From: Gonzo <42421541+gonzodepedro@users.noreply.github.com> Date: Wed, 22 Dec 2021 11:32:45 -0300 Subject: [PATCH] Fix intra process publisher message move bug (#19) Signed-off-by: Gonzalo de Pedro --- rclcpp/include/rclcpp/publisher.hpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/rclcpp/include/rclcpp/publisher.hpp b/rclcpp/include/rclcpp/publisher.hpp index e1a409976e..6afb397177 100644 --- a/rclcpp/include/rclcpp/publisher.hpp +++ b/rclcpp/include/rclcpp/publisher.hpp @@ -331,12 +331,12 @@ class Publisher : public PublisherBase get_subscription_count() > get_intra_process_subscription_count(); if (inter_process_publish_needed) { - auto shared_msg = this->do_intra_process_publish_and_return_shared(std::move(msg)); + ROSMessageType ros_msg; // TODO(clalancette): This is unnecessarily doing an additional conversion // that may have already been done in do_intra_process_publish_and_return_shared(). // We should just reuse that effort. - ROSMessageType ros_msg; rclcpp::TypeAdapter::convert_to_ros_message(*msg, ros_msg); + this->do_intra_process_publish(std::move(msg)); this->do_inter_process_publish(ros_msg); } else { this->do_intra_process_publish(std::move(msg)); @@ -535,27 +535,6 @@ class Publisher : public PublisherBase ros_message_type_allocator_); } - - std::shared_ptr - do_intra_process_publish_and_return_shared( - std::unique_ptr msg) - { - auto ipm = weak_ipm_.lock(); - if (!ipm) { - throw std::runtime_error( - "intra process publish called after destruction of intra process manager"); - } - if (!msg) { - throw std::runtime_error("cannot publish msg which is a null pointer"); - } - - return ipm->template do_intra_process_publish_and_return_shared( - intra_process_publisher_id_, - std::move(msg), - published_type_allocator_); - } - std::shared_ptr do_intra_process_ros_message_publish_and_return_shared( std::unique_ptr msg)