diff --git a/rmw_zenoh_cpp/src/detail/graph_cache.cpp b/rmw_zenoh_cpp/src/detail/graph_cache.cpp index b47c14e5..ceaad89c 100644 --- a/rmw_zenoh_cpp/src/detail/graph_cache.cpp +++ b/rmw_zenoh_cpp/src/detail/graph_cache.cpp @@ -115,7 +115,13 @@ void GraphCache::parse_put(const std::string & keyexpr) GraphNode::TopicMap::iterator cache_topic_it = graph_topics_.find(topic_info.name_); if (cache_topic_it == graph_topics_.end()) { // First time this topic name is added to the graph. - graph_topics_[topic_info.name_] = std::move(topic_data_map); + std::shared_ptr topic_data_ptr = std::make_shared( + topic_info, + TopicStats{pub_count, sub_count} + ); + graph_topics_[topic_info.name_] = GraphNode::TopicDataMap{ + {topic_info.type_, topic_data_ptr} + }; } else { // If a TopicData entry for the same type exists in the topic map, update pub/sub counts // or else create an new TopicData.