diff --git a/rosbag2/include/rosbag2/writer.hpp b/rosbag2/include/rosbag2/writer.hpp index 6a3bb78bec..341591a8c3 100644 --- a/rosbag2/include/rosbag2/writer.hpp +++ b/rosbag2/include/rosbag2/writer.hpp @@ -84,7 +84,6 @@ class ROSBAG2_PUBLIC Writer * \param topic_with_type name and type identifier of topic to be created * \throws runtime_error if the Writer is not open. */ - virtual void remove_topic(const TopicMetadata & topic_with_type); /** diff --git a/rosbag2_transport/src/rosbag2_transport/recorder.cpp b/rosbag2_transport/src/rosbag2_transport/recorder.cpp index 68138ffcd2..e5988c0913 100644 --- a/rosbag2_transport/src/rosbag2_transport/recorder.cpp +++ b/rosbag2_transport/src/rosbag2_transport/recorder.cpp @@ -106,14 +106,11 @@ void Recorder::subscribe_topics( void Recorder::subscribe_topic(const rosbag2::TopicMetadata & topic) { - if(writer_) { - writer_->create_topic(topic); - subscribed_topics_.insert(topic.name); - } - auto subscription = create_subscription(topic.name, topic.type); if (subscription) { + writer_->create_topic(topic); + subscribed_topics_.insert(topic.name); subscriptions_.push_back(subscription); ROSBAG2_TRANSPORT_LOG_INFO_STREAM("Subscribed to topic '" << topic.name << "'"); } @@ -121,7 +118,6 @@ void Recorder::subscribe_topic(const rosbag2::TopicMetadata & topic) writer_->remove_topic(topic); subscribed_topics_.erase(topic.name); } - } std::shared_ptr