Skip to content

Commit 7063d9f

Browse files
committed
fix duplicate transport override items
1 parent b1638dc commit 7063d9f

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 <QString> // NOLINT: cpplint is unable to handle the include order here
4647

@@ -117,40 +118,14 @@ ImageDisplay::ImageDisplay(std::unique_ptr<ROSImageTextureIface> texture)
117118
void ImageDisplay::onInitialize()
118119
{
119120
ITDClass::onInitialize();
120-
121121
updateNormalizeOptions();
122122
setupScreenRectangle();
123-
124123
setupRenderPanel();
125124

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

146-
void ImageDisplay::updateTopic()
147-
{
148-
if (!isEnabled()) {
149-
return;
150-
}
151-
transport_override_property_->setStdString("");
152-
153-
// Populate topic message types based on installed image_transport plugins
128+
// Populate message types and transport overrides based on installed image_transport plugins
154129
image_transport::ImageTransport image_transport_(rviz_ros_node_.lock()->get_raw_node());
155130
std::vector<std::string> loadable_transports = image_transport_.getLoadableTransports();
156131
std::vector<QString> message_types;
@@ -165,7 +140,7 @@ void ImageDisplay::updateTopic()
165140
std::string transports_str = "";
166141
rviz_common::properties::StatusProperty::Level transports_status_level =
167142
rviz_common::properties::StatusProperty::Ok;
168-
// Populate topic message types and transport override options
143+
transport_override_property_->clearOptions();
169144
transport_override_property_->addOptionStd("");
170145
for (std::string & transport : loadable_transports) {
171146
transport = transport.substr(transport.find_last_of('/') + 1);
@@ -178,14 +153,29 @@ void ImageDisplay::updateTopic()
178153
transports_str += "(unknown: " + transport + "), ";
179154
}
180155
}
156+
// TODO(mjforan) setStatus doesn't work in onInitialize or updateTopic
181157
setStatusStd(transports_status_level, "Image Transports", transports_str);
182158
// Remove duplicates
183159
message_types.erase(std::unique(message_types.begin(), message_types.end()), message_types.end());
184160
// Update the message types to allow in the topic_property_
185161
((rviz_common::properties::RosTopicMultiProperty *)topic_property_)
186162
->setMessageTypes(message_types);
163+
}
187164

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

191181
void ImageDisplay::subscribe()

0 commit comments

Comments
 (0)