3333#include " nodelet_plugin_provider.hpp"
3434
3535#include < unistd.h>
36+ #include < format>
3637#include < memory>
3738#include < stdexcept>
3839#include < string>
@@ -46,17 +47,17 @@ NodeletPluginProvider::NodeletPluginProvider(
4647 const QString & base_class_type)
4748: qt_gui_cpp::RosPluginlibPluginProvider<rqt_gui_cpp::Plugin>(export_tag, base_class_type)
4849 , loader_initialized_(false )
49- , ros_spin_thread_(0 )
50+ , ros_spin_thread_(nullptr )
5051{}
5152
5253NodeletPluginProvider::~NodeletPluginProvider ()
5354{
54- if (ros_spin_thread_ != 0 ) {
55+ if (ros_spin_thread_ != nullptr ) {
5556 ros_spin_thread_->abort = true ;
5657 ros_spin_thread_->exec_ .remove_node (node_);
5758 ros_spin_thread_->wait ();
5859 ros_spin_thread_->deleteLater ();
59- ros_spin_thread_ = 0 ;
60+ ros_spin_thread_ = nullptr ;
6061 }
6162}
6263
@@ -76,16 +77,13 @@ void NodeletPluginProvider::init_loader()
7677 loader_initialized_ = true ;
7778
7879 // spawn ros spin thread
79- if (ros_spin_thread_ == 0 ) {
80+ if (ros_spin_thread_ == nullptr ) {
8081 ros_spin_thread_ = new RosSpinThread (this );
8182 ros_spin_thread_->start ();
8283 }
8384
84- std::stringstream name;
85- name << " rqt_gui_cpp_node_" ;
86- name << getpid ();
8785 // Initialize a node for execution to be shared by cpp plugins
88- node_ = rclcpp::Node::make_shared (name. str (). c_str ( ));
86+ node_ = rclcpp::Node::make_shared (std::format ( " rqt_gui_cpp_node_{} " , getpid () ));
8987 // Add our node to the executor for execution
9088 if (ros_spin_thread_) {
9189 ros_spin_thread_->exec_ .add_node (node_);
@@ -101,8 +99,7 @@ std::shared_ptr<Plugin> NodeletPluginProvider::create_plugin(
10199{
102100 init_loader ();
103101
104- std::string nodelet_name = lookup_name + " _" +
105- QString::number (plugin_context->serialNumber ()).toStdString ();
102+ std::string nodelet_name = std::format (" {}_{}" , lookup_name, plugin_context->serialNumber ());
106103 instance_.reset ();
107104
108105 instance_ =
@@ -137,8 +134,7 @@ NodeletPluginProvider::RosSpinThread::RosSpinThread(QObject * parent)
137134 , abort(false )
138135{}
139136
140- NodeletPluginProvider::RosSpinThread::~RosSpinThread ()
141- {}
137+ NodeletPluginProvider::RosSpinThread::~RosSpinThread () = default ;
142138
143139void NodeletPluginProvider::RosSpinThread::run ()
144140{
0 commit comments