From cdfbacc69f3aed30baf069db77b0b5eab6a66194 Mon Sep 17 00:00:00 2001 From: Yadu Date: Sat, 2 Dec 2023 20:21:49 +0900 Subject: [PATCH] Instantiate new topic data for cache (#75) Signed-off-by: Yadunund --- rmw_zenoh_cpp/src/detail/graph_cache.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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.