From c7c3011dd6730acaff68177fbb645cfdf1830408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Fri, 25 Aug 2023 16:43:21 +0200 Subject: [PATCH] Fix issue with topic info. (#566) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- src/plugins/topic_viewer/TopicViewer.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index 4e7ee8b3a..7e95a79c1 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -388,11 +388,19 @@ void TopicViewer::UpdateModel() std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topics[i], publishers, subscribers); + + if (publishers.empty()) + continue; + + // ToDo: Go over all the publishers and also consider subscribers. + // Review the way we're using "topicsToRemove" as the logic doesn't look + // very clear to me. + std::string msgType = publishers[0].MsgTypeName(); // skip the matched topics if (this->dataPtr->currentTopics.count(topics[i]) && - this->dataPtr->currentTopics[topics[i]] == msgType) + this->dataPtr->currentTopics[topics[i]] == msgType) { topicsToRemove.erase(topics[i]); continue; @@ -413,7 +421,7 @@ void TopicViewer::UpdateModel() auto child = root->child(i); if (child->data(NAME_ROLE).toString().toStdString() == topic.first && - child->data(TYPE_ROLE).toString().toStdString() == topic.second) + child->data(TYPE_ROLE).toString().toStdString() == topic.second) { // remove from model root->removeRow(i);