Skip to content

Commit 8d572b4

Browse files
committed
fix duplicate transport override items
1 parent a5591eb commit 8d572b4

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
lines changed

rviz_common/include/rviz_common/properties/ros_topic_multi_property.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#ifndef RVIZ_COMMON__PROPERTIES__ROS_TOPIC_MULTI_PROPERTY_HPP_
3131
#define RVIZ_COMMON__PROPERTIES__ROS_TOPIC_MULTI_PROPERTY_HPP_
3232

33+
#include <QString>
34+
3335
#include <string>
3436
#include <vector>
3537

rviz_default_plugins/include/rviz_default_plugins/displays/image/image_display.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public Q_SLOTS:
8888
virtual void updateNormalizeOptions();
8989

9090
protected Q_SLOTS:
91-
void updateTopic() override;
9291
void subscribe() override;
9392

9493
protected:

rviz_default_plugins/src/rviz_default_plugins/displays/image/image_display.cpp

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <OgreTechnique.h>
4242
#include <OgreTextureManager.h>
4343
#include <OgreViewport.h>
44+
#include <QString>
4445

4546
#include <algorithm>
4647
#include <memory>
@@ -115,40 +116,14 @@ ImageDisplay::ImageDisplay(std::unique_ptr<ROSImageTextureIface> texture)
115116
void ImageDisplay::onInitialize()
116117
{
117118
ITDClass::onInitialize();
118-
119119
updateNormalizeOptions();
120120
setupScreenRectangle();
121-
122121
setupRenderPanel();
123122

124123
render_panel_->getRenderWindow()->setupSceneAfterInit(
125124
[this](Ogre::SceneNode * scene_node) {scene_node->attachObject(screen_rect_.get());});
126-
}
127-
128-
ImageDisplay::~ImageDisplay() = default;
129-
130-
void ImageDisplay::onEnable() {subscribe();}
131-
132-
void ImageDisplay::onDisable()
133-
{
134-
unsubscribe();
135-
clear();
136-
}
137-
138-
// Need a signature with pass by reference for image_transport_.subscribe
139-
void ImageDisplay::incomingMessage(const sensor_msgs::msg::Image::ConstSharedPtr & img_msg)
140-
{
141-
ImageTransportDisplay<sensor_msgs::msg::Image>::incomingMessage(img_msg);
142-
}
143125

144-
void ImageDisplay::updateTopic()
145-
{
146-
if (!isEnabled()) {
147-
return;
148-
}
149-
transport_override_property_->setStdString("");
150-
151-
// Populate topic message types based on installed image_transport plugins
126+
// Populate message types and transport overrides based on installed image_transport plugins
152127
image_transport::ImageTransport image_transport_(rviz_ros_node_.lock()->get_raw_node());
153128
std::vector<std::string> loadable_transports = image_transport_.getLoadableTransports();
154129
std::vector<QString> message_types;
@@ -163,7 +138,7 @@ void ImageDisplay::updateTopic()
163138
std::string transports_str = "";
164139
rviz_common::properties::StatusProperty::Level transports_status_level =
165140
rviz_common::properties::StatusProperty::Ok;
166-
// Populate topic message types and transport override options
141+
transport_override_property_->clearOptions();
167142
transport_override_property_->addOptionStd("");
168143
for (std::string & transport : loadable_transports) {
169144
transport = transport.substr(transport.find_last_of('/') + 1);
@@ -176,14 +151,29 @@ void ImageDisplay::updateTopic()
176151
transports_str += "(unknown: " + transport + "), ";
177152
}
178153
}
154+
// TODO(mjforan) setStatus doesn't work in onInitialize or updateTopic
179155
setStatusStd(transports_status_level, "Image Transports", transports_str);
180156
// Remove duplicates
181157
message_types.erase(std::unique(message_types.begin(), message_types.end()), message_types.end());
182158
// Update the message types to allow in the topic_property_
183159
((rviz_common::properties::RosTopicMultiProperty *)topic_property_)
184160
->setMessageTypes(message_types);
161+
}
185162

186-
rviz_default_plugins::displays::ImageTransportDisplay<sensor_msgs::msg::Image>::updateTopic();
163+
ImageDisplay::~ImageDisplay() = default;
164+
165+
void ImageDisplay::onEnable() {subscribe();}
166+
167+
void ImageDisplay::onDisable()
168+
{
169+
unsubscribe();
170+
clear();
171+
}
172+
173+
// Need a signature with pass by reference for image_transport_.subscribe
174+
void ImageDisplay::incomingMessage(const sensor_msgs::msg::Image::ConstSharedPtr & img_msg)
175+
{
176+
ImageTransportDisplay<sensor_msgs::msg::Image>::incomingMessage(img_msg);
187177
}
188178

189179
void ImageDisplay::subscribe()

0 commit comments

Comments
 (0)