diff --git a/include/gz/gui/MainWindow.hh b/include/gz/gui/MainWindow.hh index 2ae1c0e89..72e6d4d29 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -409,7 +409,7 @@ namespace gz::gui /// \brief Get the action performed when GUI closes without prompt. /// \return The action. - public: Q_INVOKABLE ExitAction DefaultExitAction() const; + public: Q_INVOKABLE gz::gui::ExitAction DefaultExitAction() const; /// \brief Set the action performed when GUI closes without prompt. /// \param[in] _defaultExitAction The action. diff --git a/src/Application.cc b/src/Application.cc index d6a3fb290..87201de81 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -331,7 +331,7 @@ bool Application::LoadConfig(const std::string &_config) if (!configPathEnv.empty()) { std::vector parentPaths = common::Split(configPathEnv, ':'); - for (auto parentPath : parentPaths) + for (const auto &parentPath : parentPaths) { std::string tempPath = common::joinPaths(parentPath, configFull); if (common::exists(tempPath)) @@ -364,12 +364,12 @@ bool Application::LoadConfig(const std::string &_config) // Clear all previous plugins auto plugins = this->dataPtr->mainWin->findChildren(); - for (auto plugin : plugins) + for (auto *plugin : plugins) { auto pluginName = plugin->CardItem()->objectName(); this->RemovePlugin(pluginName.toStdString()); } - if (this->dataPtr->pluginsAdded.size() > 0) + if (!this->dataPtr->pluginsAdded.empty()) { gzerr << "The plugin list was not properly cleaned up." << std::endl; } @@ -377,10 +377,11 @@ bool Application::LoadConfig(const std::string &_config) // Process each plugin bool successful = true; - for (auto pluginElem = doc.FirstChildElement("plugin"); pluginElem != nullptr; - pluginElem = pluginElem->NextSiblingElement("plugin")) + for (auto *pluginElem = doc.FirstChildElement("plugin"); + pluginElem != nullptr; + pluginElem = pluginElem->NextSiblingElement("plugin")) { - auto filename = pluginElem->Attribute("filename"); + const auto *filename = pluginElem->Attribute("filename"); if (!this->LoadPlugin(filename, pluginElem)) { successful = false; @@ -393,7 +394,7 @@ bool Application::LoadConfig(const std::string &_config) } // Process window properties - if (auto winElem = doc.FirstChildElement("window")) + if (auto *winElem = doc.FirstChildElement("window")) { gzdbg << "Loading window config" << std::endl; @@ -407,7 +408,7 @@ bool Application::LoadConfig(const std::string &_config) this->dataPtr->windowConfig.MergeFromXML(std::string(printer.CStr())); // Closing behavior. - if (auto defaultExitActionElem = + if (auto *defaultExitActionElem = winElem->FirstChildElement("default_exit_action")) { ExitAction action{ExitAction::CLOSE_GUI}; @@ -426,43 +427,43 @@ bool Application::LoadConfig(const std::string &_config) } // Dialog on exit - if (auto dialogOnExitElem = winElem->FirstChildElement("dialog_on_exit")) + if (auto *dialogOnExitElem = winElem->FirstChildElement("dialog_on_exit")) { bool showDialogOnExit{false}; dialogOnExitElem->QueryBoolText(&showDialogOnExit); this->dataPtr->mainWin->SetShowDialogOnExit(showDialogOnExit); } - if (auto dialogOnExitOptionsElem = + if (auto *dialogOnExitOptionsElem = winElem->FirstChildElement("dialog_on_exit_options")) { - if (auto promptElem = + if (auto *promptElem = dialogOnExitOptionsElem->FirstChildElement("prompt_text")) { this->dataPtr->mainWin->SetDialogOnExitText( QString::fromStdString(promptElem->GetText())); } - if (auto showShutdownElem = + if (auto *showShutdownElem = dialogOnExitOptionsElem->FirstChildElement("show_shutdown_button")) { bool showShutdownButton{false}; showShutdownElem->QueryBoolText(&showShutdownButton); this->dataPtr->mainWin->SetExitDialogShowShutdown(showShutdownButton); } - if (auto showCloseGuiElem = + if (auto *showCloseGuiElem = dialogOnExitOptionsElem->FirstChildElement("show_close_gui_button")) { bool showCloseGuiButton{false}; showCloseGuiElem->QueryBoolText(&showCloseGuiButton); this->dataPtr->mainWin->SetExitDialogShowCloseGui(showCloseGuiButton); } - if (auto shutdownTextElem = + if (auto *shutdownTextElem = dialogOnExitOptionsElem->FirstChildElement("shutdown_button_text")) { this->dataPtr->mainWin->SetExitDialogShutdownText( QString::fromStdString(shutdownTextElem->GetText())); } - if (auto closeGuiTextElem = + if (auto *closeGuiTextElem = dialogOnExitOptionsElem->FirstChildElement("close_gui_button_text")) { this->dataPtr->mainWin->SetExitDialogCloseGuiText( @@ -472,7 +473,7 @@ bool Application::LoadConfig(const std::string &_config) // Server control service topic std::string serverControlService{"/server_control"}; - auto serverControlElem = + auto *serverControlElem = winElem->FirstChildElement("server_control_service"); if (nullptr != serverControlElem && nullptr != serverControlElem->GetText()) { @@ -563,7 +564,7 @@ bool Application::LoadPlugin(const std::string &_filename, // gz::gui::Plugin interface plugin::PluginPtr commonPlugin; std::shared_ptr plugin{nullptr}; - for (auto pluginName : pluginNames) + for (const auto &pluginName : pluginNames) { commonPlugin = pluginLoader.Instantiate(pluginName); if (!commonPlugin) @@ -580,7 +581,7 @@ bool Application::LoadPlugin(const std::string &_filename, "] : couldn't instantiate plugin on path [" << pathToLib << "]. Tried plugin names: " << std::endl; - for (auto pluginName : pluginNames) + for (const auto &pluginName : pluginNames) { gzerr << " * " << pluginName << std::endl; } @@ -620,7 +621,7 @@ bool Application::LoadPlugin(const std::string &_filename, else this->InitializeDialogs(); - this->PluginAdded(plugin->CardItem()->objectName()); + emit this->PluginAdded(plugin->CardItem()->objectName()); gzmsg << "Loaded plugin [" << _filename << "] from path [" << pathToLib << "]" << std::endl; @@ -633,7 +634,7 @@ std::shared_ptr Application::PluginByName( { for (auto &plugin : this->dataPtr->pluginsAdded) { - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; @@ -683,7 +684,7 @@ bool Application::AddPluginsToWindow() return false; // Get main window background item - auto bgItem = this->dataPtr->mainWin->QuickWindow() + auto *bgItem = this->dataPtr->mainWin->QuickWindow() ->findChild("background"); if (!this->dataPtr->pluginsToAdd.empty() && !bgItem) { @@ -705,7 +706,7 @@ bool Application::AddPluginsToWindow() continue; } - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; @@ -714,7 +715,7 @@ bool Application::AddPluginsToWindow() QMetaObject::invokeMethod(bgItem, "addSplitItem", Q_RETURN_ARG(QVariant, splitName)); - auto splitItem = bgItem->findChild( + auto *splitItem = bgItem->findChild( splitName.toString()); if (!splitItem) { @@ -755,12 +756,12 @@ bool Application::InitializeDialogs() this->dataPtr->pluginsToAdd.pop(); // Create card - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; // Create dialog - auto dialog = new Dialog(); + auto *dialog = new Dialog(); if (!dialog || !dialog->QuickWindow()) continue; @@ -787,10 +788,7 @@ bool Application::InitializeDialogs() gzdbg << "Initialized dialog [" << title.toStdString() << "]" << std::endl; } - if (this->dataPtr->pluginsAdded.empty()) - return false; - - return true; + return !this->dataPtr->pluginsAdded.empty(); } ///////////////////////////////////////////////// @@ -844,7 +842,7 @@ std::vector>> ps.push_back(plugin); } - plugins.push_back(std::make_pair(path, ps)); + plugins.emplace_back(path, ps); } return plugins; diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index c3f3faefb..f23ce8ab0 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -336,7 +336,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialog after some time auto closed = false; - QTimer::singleShot(300, [&] { + QTimer::singleShot(300, &app, [&] { auto ds = app.allWindows(); // The main dialog - some systems return more, not sure why @@ -371,7 +371,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialogs after some time auto closed = false; - QTimer::singleShot(300, [&] { + QTimer::singleShot(300, &app, [&] { auto ds = app.allWindows(); // 2 dialog - some systems return more, not sure why diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index 4556cf7fa..e99f48bf4 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -171,8 +171,8 @@ TEST(HelpersTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(worldNames)) // Has names EXPECT_FALSE(worldNames().empty()); ASSERT_EQ(2, worldNames().size()); - EXPECT_EQ("banana", worldNames()[0]); - EXPECT_EQ("grape", worldNames()[1]); + EXPECT_EQ("banana", worldNames().at(0)); + EXPECT_EQ("grape", worldNames().at(1)); mainWindow->setProperty("worldNames", QStringList()); diff --git a/src/MainWindow.cc b/src/MainWindow.cc index ad075b466..bff0186a9 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -148,7 +148,7 @@ QStringList MainWindow::PluginListModel() const } // Error - for (auto plugin : this->dataPtr->windowConfig.showPlugins) + for (const auto &plugin : this->dataPtr->windowConfig.showPlugins) { if (!pluginNames.contains(QString::fromStdString(plugin))) { @@ -241,14 +241,14 @@ void MainWindow::SaveConfig(const std::string &_path) { std::string str = "Unable to open file: " + _path; str += ".\nCheck file permissions."; - this->notify(QString::fromStdString(str)); + emit this->notify(QString::fromStdString(str)); } else out << this->dataPtr->windowConfig.XMLString(); std::string msg("Saved configuration to " + _path + ""); - this->notify(QString::fromStdString(msg)); + emit this->notify(QString::fromStdString(msg)); gzmsg << msg << std::endl; } @@ -330,7 +330,7 @@ bool MainWindow::ApplyConfig(const WindowConfig &_config) this->dataPtr->windowConfig = _config; // Notify view - this->configChanged(); + emit this->configChanged(); return true; } @@ -701,7 +701,7 @@ int MainWindow::PluginCount() const void MainWindow::SetPluginCount(const int _pluginCount) { this->dataPtr->pluginCount = _pluginCount; - this->PluginCountChanged(); + emit this->PluginCountChanged(); } ///////////////////////////////////////////////// @@ -714,7 +714,7 @@ QString MainWindow::MaterialTheme() const void MainWindow::SetMaterialTheme(const QString &_materialTheme) { this->dataPtr->windowConfig.materialTheme = _materialTheme.toStdString(); - this->MaterialThemeChanged(); + emit this->MaterialThemeChanged(); } ///////////////////////////////////////////////// @@ -727,7 +727,7 @@ QString MainWindow::MaterialPrimary() const void MainWindow::SetMaterialPrimary(const QString &_materialPrimary) { this->dataPtr->windowConfig.materialPrimary = _materialPrimary.toStdString(); - this->MaterialPrimaryChanged(); + emit this->MaterialPrimaryChanged(); } ///////////////////////////////////////////////// @@ -740,7 +740,7 @@ QString MainWindow::MaterialAccent() const void MainWindow::SetMaterialAccent(const QString &_materialAccent) { this->dataPtr->windowConfig.materialAccent = _materialAccent.toStdString(); - this->MaterialAccentChanged(); + emit this->MaterialAccentChanged(); } ///////////////////////////////////////////////// @@ -754,7 +754,7 @@ void MainWindow::SetToolBarColorLight(const QString &_toolBarColorLight) { this->dataPtr->windowConfig.toolBarColorLight = _toolBarColorLight.toStdString(); - this->ToolBarColorLightChanged(); + emit this->ToolBarColorLightChanged(); } ///////////////////////////////////////////////// @@ -769,7 +769,7 @@ void MainWindow::SetToolBarTextColorLight(const QString &_toolBarTextColorLight) { this->dataPtr->windowConfig.toolBarTextColorLight = _toolBarTextColorLight.toStdString(); - this->ToolBarTextColorLightChanged(); + emit this->ToolBarTextColorLightChanged(); } ///////////////////////////////////////////////// @@ -783,7 +783,7 @@ void MainWindow::SetToolBarColorDark(const QString &_toolBarColorDark) { this->dataPtr->windowConfig.toolBarColorDark = _toolBarColorDark.toStdString(); - this->ToolBarColorDarkChanged(); + emit this->ToolBarColorDarkChanged(); } ///////////////////////////////////////////////// @@ -798,7 +798,7 @@ void MainWindow::SetToolBarTextColorDark(const QString &_toolBarTextColorDark) { this->dataPtr->windowConfig.toolBarTextColorDark = _toolBarTextColorDark.toStdString(); - this->ToolBarTextColorDarkChanged(); + emit this->ToolBarTextColorDarkChanged(); } ///////////////////////////////////////////////// @@ -814,7 +814,7 @@ void MainWindow::SetPluginToolBarColorLight( { this->dataPtr->windowConfig.pluginToolBarColorLight = _pluginToolBarColorLight.toStdString(); - this->PluginToolBarColorLightChanged(); + emit this->PluginToolBarColorLightChanged(); } ///////////////////////////////////////////////// @@ -830,7 +830,7 @@ void MainWindow::SetPluginToolBarTextColorLight( { this->dataPtr->windowConfig.pluginToolBarTextColorLight = _pluginToolBarTextColorLight.toStdString(); - this->PluginToolBarTextColorLightChanged(); + emit this->PluginToolBarTextColorLightChanged(); } ///////////////////////////////////////////////// @@ -846,7 +846,7 @@ void MainWindow::SetPluginToolBarColorDark( { this->dataPtr->windowConfig.pluginToolBarColorDark = _pluginToolBarColorDark.toStdString(); - this->PluginToolBarColorDarkChanged(); + emit this->PluginToolBarColorDarkChanged(); } ///////////////////////////////////////////////// @@ -862,7 +862,7 @@ void MainWindow::SetPluginToolBarTextColorDark( { this->dataPtr->windowConfig.pluginToolBarTextColorDark = _pluginToolBarTextColorDark.toStdString(); - this->PluginToolBarTextColorDarkChanged(); + emit this->PluginToolBarTextColorDarkChanged(); } ///////////////////////////////////////////////// @@ -881,7 +881,7 @@ bool MainWindow::ShowDrawer() const void MainWindow::SetShowDrawer(const bool _showDrawer) { this->dataPtr->windowConfig.showDrawer = _showDrawer; - this->ShowDrawerChanged(); + emit this->ShowDrawerChanged(); } ///////////////////////////////////////////////// @@ -895,7 +895,7 @@ void MainWindow::SetShowDefaultDrawerOpts(const bool _showDefaultDrawerOpts) { this->dataPtr->windowConfig.showDefaultDrawerOpts = _showDefaultDrawerOpts; - this->ShowDefaultDrawerOptsChanged(); + emit this->ShowDefaultDrawerOptsChanged(); } ///////////////////////////////////////////////// @@ -908,7 +908,7 @@ bool MainWindow::ShowPluginMenu() const void MainWindow::SetShowPluginMenu(const bool _showPluginMenu) { this->dataPtr->windowConfig.showPluginMenu = _showPluginMenu; - this->ShowPluginMenuChanged(); + emit this->ShowPluginMenuChanged(); } ///////////////////////////////////////////////// @@ -921,7 +921,7 @@ ExitAction MainWindow::DefaultExitAction() const void MainWindow::SetDefaultExitAction(ExitAction _defaultExitAction) { this->dataPtr->defaultExitAction = _defaultExitAction; - this->DefaultExitActionChanged(); + emit this->DefaultExitActionChanged(); } ///////////////////////////////////////////////// @@ -934,7 +934,7 @@ bool MainWindow::ShowDialogOnExit() const void MainWindow::SetShowDialogOnExit(bool _showDialogOnExit) { this->dataPtr->showDialogOnExit = _showDialogOnExit; - this->ShowDialogOnExitChanged(); + emit this->ShowDialogOnExitChanged(); } ///////////////////////////////////////////////// @@ -954,7 +954,7 @@ void MainWindow::SetDialogOnExitText( const QString &_dialogOnExitText) { this->dataPtr->dialogOnExitText = _dialogOnExitText; - this->DialogOnExitTextChanged(); + emit this->DialogOnExitTextChanged(); } ///////////////////////////////////////////////// @@ -967,7 +967,7 @@ bool MainWindow::ExitDialogShowShutdown() const void MainWindow::SetExitDialogShowShutdown(bool _exitDialogShowShutdown) { this->dataPtr->exitDialogShowShutdown = _exitDialogShowShutdown; - this->ExitDialogShowShutdownChanged(); + emit this->ExitDialogShowShutdownChanged(); } ///////////////////////////////////////////////// @@ -980,7 +980,7 @@ bool MainWindow::ExitDialogShowCloseGui() const void MainWindow::SetExitDialogShowCloseGui(bool _exitDialogShowCloseGui) { this->dataPtr->exitDialogShowCloseGui = _exitDialogShowCloseGui; - this->ExitDialogShowCloseGuiChanged(); + emit this->ExitDialogShowCloseGuiChanged(); } ///////////////////////////////////////////////// @@ -994,7 +994,7 @@ void MainWindow::SetExitDialogShutdownText( const QString &_exitDialogShutdownText) { this->dataPtr->exitDialogShutdownText = _exitDialogShutdownText; - this->ExitDialogShutdownTextChanged(); + emit this->ExitDialogShutdownTextChanged(); } ///////////////////////////////////////////////// @@ -1008,7 +1008,7 @@ void MainWindow::SetExitDialogCloseGuiText( const QString &_exitDialogCloseGuiText) { this->dataPtr->exitDialogCloseGuiText = _exitDialogCloseGuiText; - this->ExitDialogCloseGuiTextChanged(); + emit this->ExitDialogCloseGuiTextChanged(); } ///////////////////////////////////////////////// diff --git a/src/MainWindow_TEST.cc b/src/MainWindow_TEST.cc index c5c12e21d..f81749b61 100644 --- a/src/MainWindow_TEST.cc +++ b/src/MainWindow_TEST.cc @@ -342,7 +342,7 @@ TEST(MainWindowTest, // Access window after it's open bool closed{false}; - QTimer::singleShot(300, [&closed] + QTimer::singleShot(300, App(), [&closed] { auto win = App()->findChild(); ASSERT_NE(nullptr, win); @@ -519,7 +519,10 @@ void FindExitDialogButtons( ASSERT_NE(nullptr, dialog); QObject *buttonBox{nullptr}; - for (const auto& c : dialog->findChildren()) + // Qt considers range-based for loops over temporary objects + // potentially dangerous, so explicitly create a container. + const auto children = dialog->findChildren(); + for (const auto& c : children) { if (std::string(c->metaObject()->className()).find("ButtonBox") != std::string::npos) @@ -539,9 +542,9 @@ void FindExitDialogButtons( std::vector buttons; for (int index = 0; index < buttonCount; ++index) { - QQuickItem *button; + QQuickItem *button {nullptr}; QMetaObject::invokeMethod(buttonBox, "itemAt", Qt::DirectConnection, - Q_RETURN_ARG(QQuickItem *, button), + Q_RETURN_ARG(QQuickItem*, button), Q_ARG(int, index)); ASSERT_NE(std::string::npos, diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index 1ac0af2f5..b44ffcb10 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -161,7 +161,7 @@ Topic::Topic(const std::string &_name): ////////////////////////////////////////////////////// Topic::~Topic() { - for (auto field : this->dataPtr->fields) + for (const auto &field : this->dataPtr->fields) delete field.second; } @@ -207,7 +207,7 @@ std::map &Topic::Fields() void Topic::Callback(const google::protobuf::Message &_msg) { // check for header time - double headerTime; + double headerTime = 0.0; if (!this->HasHeader(_msg, headerTime)) { if (!this->dataPtr->plottingTime) @@ -230,10 +230,10 @@ void Topic::Callback(const google::protobuf::Message &_msg) } // loop over the registered fields and update them - for (auto fieldIt : this->dataPtr->fields) + for (const auto &fieldIt : this->dataPtr->fields) { - auto msgDescriptor = _msg.GetDescriptor(); - auto ref = _msg.GetReflection(); + const auto *msgDescriptor = _msg.GetDescriptor(); + const auto *ref = _msg.GetReflection(); google::protobuf::Message *valueMsg = nullptr; @@ -245,7 +245,7 @@ void Topic::Callback(const google::protobuf::Message &_msg) { std::string fieldName = fieldFullPath[i]; - auto field = msgDescriptor->FindFieldByName(fieldName); + const auto *field = msgDescriptor->FindFieldByName(fieldName); msgDescriptor = field->message_type(); @@ -270,16 +270,16 @@ void Topic::Callback(const google::protobuf::Message &_msg) } std::string fieldName = fieldFullPath[pathSize-1]; - double data; + double data = 0.0; if (valueMsg) { - auto field = valueMsg->GetDescriptor()->FindFieldByName(fieldName); + const auto *field = valueMsg->GetDescriptor()->FindFieldByName(fieldName); data = this->dataPtr->FieldData(*valueMsg, field); } else { - auto field = msgDescriptor->FindFieldByName(fieldName); + const auto *field = msgDescriptor->FindFieldByName(fieldName); data = this->dataPtr->FieldData(_msg, field); } @@ -301,19 +301,19 @@ void Topic::Callback(const google::protobuf::Message &_msg) bool Topic::HasHeader(const google::protobuf::Message &_msg, double &_headerTime) { - auto ref = _msg.GetReflection(); - auto header = _msg.GetDescriptor()->FindFieldByName("header"); + const auto *ref = _msg.GetReflection(); + const auto *header = _msg.GetDescriptor()->FindFieldByName("header"); auto found = ref->HasField(_msg, header); if (!found) return false; - auto stamp = header->message_type()->FindFieldByName("stamp"); + const auto *stamp = header->message_type()->FindFieldByName("stamp"); if (!stamp) return false; - auto headerMsg = ref->MutableMessage + auto *headerMsg = ref->MutableMessage (const_cast(&_msg), header); if (!headerMsg) @@ -321,14 +321,14 @@ bool Topic::HasHeader(const google::protobuf::Message &_msg, ref = headerMsg->GetReflection(); - auto stampMsg = ref->MutableMessage + auto *stampMsg = ref->MutableMessage (const_cast(headerMsg), stamp); if (!stampMsg) return false; - auto secField = stamp->message_type()->FindFieldByName("sec"); - auto nsecField = stamp->message_type()->FindFieldByName("nsec"); + const auto *secField = stamp->message_type()->FindFieldByName("sec"); + const auto *nsecField = stamp->message_type()->FindFieldByName("nsec"); auto sec = this->dataPtr->FieldData(*stampMsg, secField); auto nsec = this->dataPtr->FieldData(*stampMsg, nsecField); @@ -341,7 +341,7 @@ bool Topic::HasHeader(const google::protobuf::Message &_msg, ////////////////////////////////////////////////////// void Topic::UpdateGui(const std::string &_field) { - auto field = this->dataPtr->fields[_field]; + auto *field = this->dataPtr->fields[_field]; auto x = field->Time(); auto y = field->Value(); @@ -366,8 +366,8 @@ void Topic::SetPlottingTimeRef(const std::shared_ptr &_timeRef) double Topic::Implementation::FieldData(const google::protobuf::Message &_msg, const google::protobuf::FieldDescriptor *_field) { - using namespace google::protobuf; - auto ref = _msg.GetReflection(); + using FieldDescriptor = google::protobuf::FieldDescriptor; + const auto *ref = _msg.GetReflection(); auto type = _field->type(); if (type == FieldDescriptor::Type::TYPE_DOUBLE) @@ -401,7 +401,7 @@ Transport::Transport(): Transport::~Transport() { // unsubscribe from all topics in the transport - for (auto topic : this->dataPtr->topics) + for (const auto &topic : this->dataPtr->topics) this->dataPtr->node.Unsubscribe(topic.first); } @@ -431,7 +431,7 @@ void Transport::Subscribe(const std::string &_topic, // new topic if (this->dataPtr->topics.count(_topic) == 0) { - auto topicHandler = new Topic(_topic); + auto *topicHandler = new Topic(_topic); this->dataPtr->topics[_topic] = topicHandler; topicHandler->Register(_fieldPath, _chart); @@ -470,7 +470,7 @@ void Transport::UnsubscribeOutdatedTopics() std::vector topics; this->dataPtr->node.TopicList(topics); - for (auto topic : this->dataPtr->topics) + for (const auto &topic : this->dataPtr->topics) { // check if the topic exist if (std::find(topics.begin(), topics.end(), topic.first) == topics.end()) @@ -483,7 +483,7 @@ void Transport::UnsubscribeOutdatedTopics() } ////////////////////////////////////////////////////// -PlottingInterface::PlottingInterface() : QObject(), +PlottingInterface::PlottingInterface(): dataPtr(gz::utils::MakeUniqueImpl()) { connect(&this->dataPtr->transport, diff --git a/src/Plugin.cc b/src/Plugin.cc index 2f9e7855d..c36f36dd3 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -143,7 +143,10 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) std::stringstream errors; errors << "Failed to instantiate QML file [" << qmlFile << "]." << std::endl; - for (auto error : component.errors()) + // Qt considers range-based for loops over temporary objects + // potentially dangerous, so explicitly create a container. + const auto componentErrors = component.errors(); + for (const auto &error : componentErrors) { errors << "* " << error.toString().toStdString() << std::endl; } @@ -170,7 +173,7 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } // Load common configuration - auto guiElem = _pluginElem->FirstChildElement("gz-gui"); + const auto *guiElem = _pluginElem->FirstChildElement("gz-gui"); if (guiElem) { this->LoadCommonConfig(_pluginElem->FirstChildElement("gz-gui")); @@ -186,7 +189,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) if (nullptr == _guiElem) return; - auto elem = _guiElem->FirstChildElement("title"); + const auto *elem = _guiElem->FirstChildElement("title"); if (nullptr != elem && nullptr != elem->GetText()) { this->title = elem->GetText(); @@ -205,7 +208,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) } // Properties - for (auto propElem = _guiElem->FirstChildElement("property"); + for (const auto *propElem = _guiElem->FirstChildElement("property"); propElem != nullptr; propElem = propElem->NextSiblingElement("property")) { @@ -215,19 +218,19 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) if (type == "bool") { - bool value; + bool value = false; propElem->QueryBoolText(&value); variant = QVariant(value); } else if (type == "int") { - int value; + int value = 0; propElem->QueryIntText(&value); variant = QVariant(value); } else if (type == "double") { - double value; + double value = 0.0; propElem->QueryDoubleText(&value); variant = QVariant(value); } @@ -251,17 +254,17 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) } // Anchors - if (auto anchorElem = _guiElem->FirstChildElement("anchors")) + if (const auto *anchorElem = _guiElem->FirstChildElement("anchors")) { this->dataPtr->anchors.target = anchorElem->Attribute("target"); this->dataPtr->anchors.lines.clear(); - for (auto lineElem = anchorElem->FirstChildElement("line"); + for (const auto *lineElem = anchorElem->FirstChildElement("line"); lineElem != nullptr; lineElem = lineElem->NextSiblingElement("line")) { - auto ownLine = lineElem->Attribute("own"); - auto targetLine = lineElem->Attribute("target"); + const auto *ownLine = lineElem->Attribute("own"); + const auto *targetLine = lineElem->Attribute("target"); if (kAnchorLineSet.find(ownLine) == kAnchorLineSet.end()) { @@ -276,8 +279,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) continue; } - this->dataPtr->anchors.lines.push_back( - std::make_pair(ownLine, targetLine)); + this->dataPtr->anchors.lines.emplace_back(ownLine, targetLine); } } } @@ -293,7 +295,7 @@ std::string Plugin::ConfigStr() doc.Parse(this->configStr.c_str()); // - auto pluginElem = doc.FirstChildElement("plugin"); + auto *pluginElem = doc.FirstChildElement("plugin"); if (!pluginElem) { // LCOV_EXCL_START @@ -304,7 +306,7 @@ std::string Plugin::ConfigStr() } // - auto guiElem = pluginElem->FirstChildElement("gz-gui"); + auto *guiElem = pluginElem->FirstChildElement("gz-gui"); if (!guiElem) { guiElem = doc.NewElement("gz-gui"); @@ -312,23 +314,23 @@ std::string Plugin::ConfigStr() } // Clean s - for (auto propElem = guiElem->FirstChildElement("property"); + for (auto *propElem = guiElem->FirstChildElement("property"); propElem != nullptr;) { - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); guiElem->DeleteChild(propElem); propElem = nextProp; } // Add s - auto meta = this->CardItem()->metaObject(); + const auto *meta = this->CardItem()->metaObject(); for (int i = 0; i < meta->propertyCount(); ++i) { - auto key = meta->property(i).name(); + const auto *key = meta->property(i).name(); auto type = std::string(meta->property(i).typeName()); // Explicitly skip some keys - if (kIgnoredProps.find(key) != kAnchorLineSet.end()) + if (kIgnoredProps.find(key) != kIgnoredProps.end()) continue; // When setting, it will need to be string @@ -344,7 +346,7 @@ std::string Plugin::ConfigStr() value = this->CardItem()->property(meta->property(i).name()) .toString().toStdString(); - auto elem = doc.NewElement("property"); + auto *elem = doc.NewElement("property"); elem->SetAttribute("key", key); elem->SetAttribute("type", type.c_str()); elem->SetText(value.c_str()); @@ -356,10 +358,10 @@ std::string Plugin::ConfigStr() auto anchored = this->CardItem()->property("anchored").toBool(); if (!anchored) { - for (auto anchorElem = guiElem->FirstChildElement("anchors"); + for (auto *anchorElem = guiElem->FirstChildElement("anchors"); anchorElem != nullptr;) { - auto nextAnchor = anchorElem->NextSiblingElement("anchors"); + auto *nextAnchor = anchorElem->NextSiblingElement("anchors"); guiElem->DeleteChild(anchorElem); anchorElem = nextAnchor; } @@ -420,9 +422,8 @@ QQuickItem *Plugin::CardItem() const // Instantiate a card std::string qmlFile(":qml/GzCard.qml"); - QQmlComponent cardComp(App()->Engine(), - QString(QString::fromStdString(qmlFile))); - auto cardItem = qobject_cast(cardComp.create()); + QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile)); + auto *cardItem = qobject_cast(cardComp.create()); if (!cardItem) { gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile @@ -434,14 +435,14 @@ QQuickItem *Plugin::CardItem() const QQmlEngine::setObjectOwnership(cardItem, QQmlEngine::CppOwnership); // Get card parts - auto cardContentItem = cardItem->findChild("content"); + auto *cardContentItem = cardItem->findChild("content"); if (!cardContentItem) { gzerr << "Null card content QQuickItem!" << std::endl; return nullptr; } - auto cardToolbarItem = cardItem->findChild("cardToolbar"); + auto *cardToolbarItem = cardItem->findChild("cardToolbar"); if (!cardToolbarItem) { gzerr << "Null toolbar content QQuickItem!" << std::endl; @@ -452,7 +453,7 @@ QQuickItem *Plugin::CardItem() const cardItem->setProperty("pluginName", QString::fromStdString(this->Title())); - for (auto prop : this->dataPtr->cardProperties) + for (const auto &prop : this->dataPtr->cardProperties) { // Skip and only apply once it's reparented if (prop.first == "state") @@ -509,7 +510,7 @@ void Plugin::PostParentChanges() this->ApplyAnchors(); // Re-apply other properties like size and position if present - for (auto prop : this->dataPtr->cardProperties) + for (const auto &prop : this->dataPtr->cardProperties) { if (prop.first == "state") continue; @@ -550,14 +551,14 @@ void Plugin::ApplyAnchors() if (this->dataPtr->anchors.target == "window") { - auto win = App()->findChild(); + auto *win = App()->findChild(); if (!win) { gzerr << "Internal error: missing window" << std::endl; return; } - auto bgItem = win->QuickWindow()->findChild("background"); + auto *bgItem = win->QuickWindow()->findChild("background"); if (!bgItem) { gzerr << "Internal error: missing background item" << std::endl; @@ -588,9 +589,9 @@ void Plugin::ApplyAnchors() QMetaObject::invokeMethod(this->CardItem(), "clearAnchors"); // Set anchors - auto cardAnchors = qvariant_cast( + auto *cardAnchors = qvariant_cast( this->CardItem()->property("anchors")); - for (auto line : this->dataPtr->anchors.lines) + for (const auto &line : this->dataPtr->anchors.lines) { cardAnchors->setProperty(line.first.c_str(), target->property(line.second.c_str())); diff --git a/src/Plugin_TEST.cc b/src/Plugin_TEST.cc index fefe02b4f..76d9fa78c 100644 --- a/src/Plugin_TEST.cc +++ b/src/Plugin_TEST.cc @@ -130,7 +130,7 @@ TEST(PluginTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Getters)) EXPECT_EQ(1, win->findChildren().size()); // Get pointers - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); ASSERT_NE(nullptr, plugin->PluginItem()); ASSERT_NE(nullptr, plugin->CardItem()); ASSERT_NE(nullptr, plugin->Context()); @@ -185,7 +185,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) pluginDoc.FirstChildElement("plugin"))); // Create main window - auto win = app.findChild(); + auto *win = app.findChild(); ASSERT_NE(nullptr, win); // Check plugin count @@ -194,20 +194,20 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) // Get the output for ConfigStr() std::string configStr; tinyxml2::XMLDocument configDoc; - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); configStr = plugin->ConfigStr(); configDoc.Parse(configStr.c_str()); // - auto pluginElem = configDoc.FirstChildElement("plugin"); + auto *pluginElem = configDoc.FirstChildElement("plugin"); ASSERT_NE(nullptr, pluginElem); // - auto gzGuiElem = pluginElem->FirstChildElement("gz-gui"); + auto *gzGuiElem = pluginElem->FirstChildElement("gz-gui"); ASSERT_NE(nullptr, gzGuiElem); // Iterate properties - for (auto propElem = gzGuiElem->FirstChildElement("property"); + for (auto *propElem = gzGuiElem->FirstChildElement("property"); propElem != nullptr;) { // If property in map, mark it as "Verified" @@ -222,7 +222,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) << propElem->Attribute("key"); pluginProps[propElem->Attribute("key")] = "Verified"; } - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); propElem = nextProp; } @@ -253,7 +253,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) pluginDoc.FirstChildElement("plugin"))); // Create main window - auto win = app.findChild(); + auto *win = app.findChild(); ASSERT_NE(nullptr, win); // Check plugin count @@ -262,7 +262,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) // Get the output for ConfigStr() std::string configStr; tinyxml2::XMLDocument configDoc; - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); configStr = plugin->ConfigStr(); configDoc.Parse(configStr.c_str()); @@ -286,15 +286,15 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) pluginTypes["state"] = "string"; // - auto pluginElem = configDoc.FirstChildElement("plugin"); + auto *pluginElem = configDoc.FirstChildElement("plugin"); ASSERT_NE(nullptr, pluginElem); // - auto gzGuiElem = pluginElem->FirstChildElement("gz-gui"); + auto *gzGuiElem = pluginElem->FirstChildElement("gz-gui"); ASSERT_NE(nullptr, gzGuiElem); // Iterate properties - for (auto propElem = gzGuiElem->FirstChildElement("property"); + for (auto *propElem = gzGuiElem->FirstChildElement("property"); propElem != nullptr;) { // If property in map, mark it as "Verified" @@ -309,7 +309,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) << propElem->Attribute("key"); pluginProps[propElem->Attribute("key")] = "Verified"; } - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); propElem = nextProp; } @@ -320,4 +320,3 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) << itr->first; } } - diff --git a/src/SearchModel.cc b/src/SearchModel.cc index 6a41d93b1..795cb9958 100644 --- a/src/SearchModel.cc +++ b/src/SearchModel.cc @@ -47,7 +47,7 @@ bool SearchModel::filterAcceptsRow(const int _srcRow, // Each word must match at least once, either self, parent or child. auto words = this->search.split(" "); - for (auto word : words) + for (const auto &word : words) { if (word.isEmpty()) continue; @@ -152,6 +152,6 @@ void SearchModel::SetSearch(const QString &_search) // TODO(anyone): Figure out why filterChanged works for TopicViewer but not // TopicsStats - this->layoutChanged(); + emit this->layoutChanged(); } } // namespace gz::gui diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/camera_fps/CameraFps.cc index 6dc385b31..fa5e08a26 100644 --- a/src/plugins/camera_fps/CameraFps.cc +++ b/src/plugins/camera_fps/CameraFps.cc @@ -120,7 +120,7 @@ QString CameraFps::CameraFpsValue() const void CameraFps::SetCameraFpsValue(const QString &_value) { this->dataPtr->cameraFPSValue = _value; - this->CameraFpsValueChanged(); + emit this->CameraFpsValueChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 6f514edd6..cdf71cc97 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -434,7 +434,7 @@ CameraTracking::CameraTracking() : dataPtr(gz::utils::MakeUniqueImpl()) { this->dataPtr->timer = new QTimer(this); - this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() + connect(this->dataPtr->timer, &QTimer::timeout, this->dataPtr->timer, [=]() { std::lock_guard lock(this->dataPtr->mutex); if (!this->dataPtr->camera) diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/grid_config/GridConfig.cc index e6bb9a0ae..a49dd7a8d 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -286,7 +286,7 @@ void GridConfig::ConnectToGrid() this->dataPtr->gridParam.cellLength = grid->CellLength(); this->dataPtr->gridParam.pose = grid->Parent()->LocalPose(); this->dataPtr->gridParam.color = grid->Parent()->Material()->Ambient(); - this->newParams( + emit this->newParams( grid->CellCount(), grid->VerticalCellCount(), grid->CellLength(), @@ -320,7 +320,7 @@ QStringList GridConfig::NameList() const void GridConfig::SetNameList(const QStringList &_nameList) { this->dataPtr->nameList = _nameList; - this->NameListChanged(); + emit this->NameListChanged(); } ///////////////////////////////////////////////// @@ -403,7 +403,7 @@ void GridConfig::RefreshList() // Select first one if (this->dataPtr->nameList.count() > 0) this->OnName(this->dataPtr->nameList.at(0)); - this->NameListChanged(); + emit this->NameListChanged(); } } // namespace gz::gui diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/image_display/ImageDisplay.cc index 85c648d23..d0a090d49 100644 --- a/src/plugins/image_display/ImageDisplay.cc +++ b/src/plugins/image_display/ImageDisplay.cc @@ -179,7 +179,7 @@ void ImageDisplay::ProcessImage() } this->dataPtr->provider->SetImage(image); - this->newImage(); + emit this->newImage(); } ///////////////////////////////////////////////// @@ -205,7 +205,7 @@ void ImageDisplay::OnTopic(const QString _topic) // Unsubscribe auto subs = this->dataPtr->node.SubscribedTopics(); - for (auto sub : subs) + for (const auto &sub : subs) this->dataPtr->node.Unsubscribe(sub); // Subscribe to new topic @@ -217,7 +217,7 @@ void ImageDisplay::OnTopic(const QString _topic) return; // LCOV_EXCL_STOP } - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Subscribed to: " + topic + ""), 4000); } @@ -230,12 +230,12 @@ void ImageDisplay::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.Image") { @@ -248,7 +248,7 @@ void ImageDisplay::OnRefresh() // Select first one if (this->dataPtr->topicList.count() > 0) this->OnTopic(this->dataPtr->topicList.at(0)); - this->TopicListChanged(); + emit this->TopicListChanged(); } ///////////////////////////////////////////////// @@ -261,7 +261,7 @@ QStringList ImageDisplay::TopicList() const void ImageDisplay::SetTopicList(const QStringList &_topicList) { this->dataPtr->topicList = _topicList; - this->TopicListChanged(); + emit this->TopicListChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/marker_manager/MarkerManager.cc index 811e86435..4a605eaf5 100644 --- a/src/plugins/marker_manager/MarkerManager.cc +++ b/src/plugins/marker_manager/MarkerManager.cc @@ -252,9 +252,9 @@ bool MarkerManager::Implementation::OnList(gz::msgs::Marker_V &_rep) _rep.clear_marker(); // Create the list of visuals - for (auto mIter : this->visuals) + for (const auto &mIter : this->visuals) { - for (auto iter : mIter.second) + for (const auto &iter : mIter.second) { gz::msgs::Marker *markerMsg = _rep.add_marker(); markerMsg->set_ns(mIter.first); @@ -284,7 +284,8 @@ bool MarkerManager::Implementation::OnMarkerMsgArray( } ////////////////////////////////////////////////// -bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_msg) +bool MarkerManager::Implementation::ProcessMarkerMsg( + const gz::msgs::Marker &_msg) { // Get the namespace, if it exists. Otherwise, use the global namespace std::string ns; @@ -419,7 +420,7 @@ bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_ms // Remove all markers in the specified namespace else if (nsIter != this->visuals.end()) { - for (auto it : nsIter->second) + for (const auto &it : nsIter->second) { this->scene->DestroyVisual(it.second); } @@ -432,7 +433,7 @@ bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_ms for (nsIter = this->visuals.begin(); nsIter != this->visuals.end(); ++nsIter) { - for (auto it : nsIter->second) + for (const auto &it : nsIter->second) { this->scene->DestroyVisual(it.second); } diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 556ea8e10..7b92cf407 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -1129,7 +1129,7 @@ RenderWindowItem::~RenderWindowItem() void RenderWindowItem::StopRendering() { // Disconnect our QT connections. - for(auto conn : this->dataPtr->connections) + for (const auto &conn : qAsConst(this->dataPtr->connections)) QObject::disconnect(conn); this->dataPtr->renderSync.Shutdown(); @@ -1692,7 +1692,7 @@ void MinimalScene::SetLoadingError(const QString &_loadingError) renderWindow->StopRendering(); } this->loadingError = _loadingError; - this->LoadingErrorChanged(); + emit this->LoadingErrorChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index e277a77b5..5f8bd433d 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -264,7 +264,7 @@ namespace gz::gui::plugins /// \brief Render when safe /// \param[in] _renderSync RenderSync to safely /// synchronize Qt and worker thread (this) - public slots: void RenderNext(RenderSync *_renderSync); + public slots: void RenderNext(gz::gui::plugins::RenderSync *_renderSync); /// \brief Shutdown the thread and the render engine public slots: void ShutDown(); @@ -380,101 +380,101 @@ namespace gz::gui::plugins /// \param[in] _view_controller The camera view controller type to set public: void SetCameraViewController(const std::string &_view_controller); - /// \brief Slot called when thread is ready to be started - public Q_SLOTS: void Ready(); + /// \brief Slot called when thread is ready to be started + public Q_SLOTS: void Ready(); - /// \brief Handle key press event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyPress(const common::KeyEvent &_e); + /// \brief Handle key press event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyPress(const common::KeyEvent &_e); - /// \brief Handle key release event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyRelease(const common::KeyEvent &_e); + /// \brief Handle key release event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyRelease(const common::KeyEvent &_e); - /// \brief Set a callback to be called in case there are errors. - /// \param[in] _cb Error callback - public: void SetErrorCb(std::function _cb); + /// \brief Set a callback to be called in case there are errors. + /// \param[in] _cb Error callback + public: void SetErrorCb(std::function _cb); - /// \brief Stop rendering and shutdown resources. - public: void StopRendering(); + /// \brief Stop rendering and shutdown resources. + public: void StopRendering(); - // Documentation inherited - protected: virtual void mousePressEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mousePressEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void keyPressEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyPressEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void wheelEvent(QWheelEvent *_e) override; + // Documentation inherited + protected: virtual void wheelEvent(QWheelEvent *_e) override; - /// \brief Overrides the paint event to render the render engine - /// camera view - /// \param[in] _oldNode The node passed in previous updatePaintNode - /// function. It represents the visual representation of the item. - /// \param[in] _data The node transformation data. - /// \return Updated node. - private: QSGNode *updatePaintNode(QSGNode *_oldNode, - QQuickItem::UpdatePaintNodeData *_data) override; + /// \brief Overrides the paint event to render the render engine + /// camera view + /// \param[in] _oldNode The node passed in previous updatePaintNode + /// function. It represents the visual representation of the item. + /// \param[in] _data The node transformation data. + /// \return Updated node. + private: QSGNode *updatePaintNode(QSGNode *_oldNode, + QQuickItem::UpdatePaintNodeData *_data) override; - /// \internal - /// \brief Pointer to private data. - GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; - - /// \brief Texture node for displaying the render texture from gz-renderer - class TextureNode : public QObject, public QSGSimpleTextureNode - { - Q_OBJECT - - /// \brief Constructor - /// \param[in] _window Window to display the texture - /// \param[in] _renderSync RenderSync to safely - /// synchronize Qt (this) and worker thread - /// \param[in] _graphicsAPI The type of graphics API - /// \param[in] _camera Camera owning the Texture Handle - public: explicit TextureNode(QQuickWindow *_window, - RenderSync &_renderSync, - const rendering::GraphicsAPI &_graphicsAPI, - rendering::CameraPtr &_camera); - - /// \brief Destructor - public: ~TextureNode() override; + /// \internal + /// \brief Pointer to private data. + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; - /// \brief This function gets called on the FBO rendering thread and will - /// store the texture id and size and schedule an update on the window. - /// \param[in] _texturePtr Pointer to a texture Id - /// \param[in] _size Texture size - // public slots: void NewTexture(uint _id, const QSize &_size); - public slots: void NewTexture(void* _texturePtr, const QSize &_size); - - /// \brief Before the scene graph starts to render, we update to the - /// pending texture - public slots: void PrepareNode(); - - /// \param[in] _renderSync RenderSync to send to the worker thread - signals: void TextureInUse(RenderSync *_renderSync); - - /// \brief Signal emitted when a new texture is ready to trigger window - /// update - signals: void PendingNewTexture(); - - /// \brief Texture size - public: QSize size = QSize(0, 0); - - /// \brief Mutex to protect the texture variables - public: QMutex mutex; - - /// \brief See RenderSync - public: RenderSync &renderSync; +/// \brief Texture node for displaying the render texture from gz-renderer +class TextureNode : public QObject, public QSGSimpleTextureNode +{ + Q_OBJECT + + /// \brief Constructor + /// \param[in] _window Window to display the texture + /// \param[in] _renderSync RenderSync to safely + /// synchronize Qt (this) and worker thread + /// \param[in] _graphicsAPI The type of graphics API + /// \param[in] _camera Camera owning the Texture Handle + public: explicit TextureNode(QQuickWindow *_window, + RenderSync &_renderSync, + const rendering::GraphicsAPI &_graphicsAPI, + rendering::CameraPtr &_camera); + + /// \brief Destructor + public: ~TextureNode() override; + + /// \brief This function gets called on the FBO rendering thread and will + /// store the texture id and size and schedule an update on the window. + /// \param[in] _texturePtr Pointer to a texture Id + /// \param[in] _size Texture size + // public slots: void NewTexture(uint _id, const QSize &_size); + public slots: void NewTexture(void* _texturePtr, const QSize &_size); + + /// \brief Before the scene graph starts to render, we update to the + /// pending texture + public slots: void PrepareNode(); + + /// \param[in] _renderSync RenderSync to send to the worker thread + signals: void TextureInUse(gz::gui::plugins::RenderSync *_renderSync); + + /// \brief Signal emitted when a new texture is ready to trigger window + /// update + signals: void PendingNewTexture(); + + /// \brief Texture size + public: QSize size = QSize(0, 0); + + /// \brief Mutex to protect the texture variables + public: QMutex mutex; + + /// \brief See RenderSync + public: RenderSync &renderSync; /// \brief Qt quick window public: QQuickWindow *window = nullptr; diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/navsat_map/NavSatMap.cc index 86333c373..8cd189cf0 100644 --- a/src/plugins/navsat_map/NavSatMap.cc +++ b/src/plugins/navsat_map/NavSatMap.cc @@ -97,7 +97,7 @@ void NavSatMap::ProcessMessage() { std::lock_guard lock(this->dataPtr->navSatMutex); - this->newMessage(this->dataPtr->navSatMsg.latitude_deg(), + emit this->newMessage(this->dataPtr->navSatMsg.latitude_deg(), this->dataPtr->navSatMsg.longitude_deg()); } @@ -120,7 +120,7 @@ void NavSatMap::OnTopic(const QString _topic) // Unsubscribe auto subs = this->dataPtr->node.SubscribedTopics(); - for (auto sub : subs) + for (const auto &sub : subs) this->dataPtr->node.Unsubscribe(sub); // Subscribe to new topic @@ -140,12 +140,12 @@ void NavSatMap::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.NavSat") { @@ -158,7 +158,7 @@ void NavSatMap::OnRefresh() // Select first one if (this->dataPtr->topicList.count() > 0) this->OnTopic(this->dataPtr->topicList.at(0)); - this->TopicListChanged(); + emit this->TopicListChanged(); } ///////////////////////////////////////////////// @@ -171,7 +171,7 @@ QStringList NavSatMap::TopicList() const void NavSatMap::SetTopicList(const QStringList &_topicList) { this->dataPtr->topicList = _topicList; - this->TopicListChanged(); + emit this->TopicListChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index 6bd01665e..309dd89da 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -234,12 +234,12 @@ void PointCloud::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.PointCloudPacked") { @@ -254,17 +254,17 @@ void PointCloud::OnRefresh() } // Handle floats first, so by the time we get the point cloud it can be // colored - if (this->dataPtr->floatVTopicList.size() > 0) + if (!this->dataPtr->floatVTopicList.empty()) { this->OnFloatVTopic(this->dataPtr->floatVTopicList.at(0)); } - if (this->dataPtr->pointCloudTopicList.size() > 0) + if (!this->dataPtr->pointCloudTopicList.empty()) { this->OnPointCloudTopic(this->dataPtr->pointCloudTopicList.at(0)); } - this->PointCloudTopicListChanged(); - this->FloatVTopicListChanged(); + emit this->PointCloudTopicListChanged(); + emit this->FloatVTopicListChanged(); } ///////////////////////////////////////////////// @@ -278,7 +278,7 @@ void PointCloud::SetPointCloudTopicList( const QStringList &_pointCloudTopicList) { this->dataPtr->pointCloudTopicList = _pointCloudTopicList; - this->PointCloudTopicListChanged(); + emit this->PointCloudTopicListChanged(); } ///////////////////////////////////////////////// @@ -292,7 +292,7 @@ void PointCloud::SetFloatVTopicList( const QStringList &_floatVTopicList) { this->dataPtr->floatVTopicList = _floatVTopicList; - this->FloatVTopicListChanged(); + emit this->FloatVTopicListChanged(); } ////////////////////////////////////////////////// @@ -461,7 +461,7 @@ QColor PointCloud::MinColor() const void PointCloud::SetMinColor(const QColor &_minColor) { this->dataPtr->minColor = gz::gui::convert(_minColor); - this->MinColorChanged(); + emit this->MinColorChanged(); this->dataPtr->PublishMarkers(); } @@ -475,7 +475,7 @@ QColor PointCloud::MaxColor() const void PointCloud::SetMaxColor(const QColor &_maxColor) { this->dataPtr->maxColor = gz::gui::convert(_maxColor); - this->MaxColorChanged(); + emit this->MaxColorChanged(); this->dataPtr->PublishMarkers(); } @@ -489,7 +489,7 @@ float PointCloud::MinFloatV() const void PointCloud::SetMinFloatV(float _minFloatV) { this->dataPtr->minFloatV = _minFloatV; - this->MinFloatVChanged(); + emit this->MinFloatVChanged(); } ///////////////////////////////////////////////// @@ -502,7 +502,7 @@ float PointCloud::MaxFloatV() const void PointCloud::SetMaxFloatV(float _maxFloatV) { this->dataPtr->maxFloatV = _maxFloatV; - this->MaxFloatVChanged(); + emit this->MaxFloatVChanged(); } ///////////////////////////////////////////////// @@ -515,7 +515,7 @@ float PointCloud::PointSize() const void PointCloud::SetPointSize(float _pointSize) { this->dataPtr->pointSize = _pointSize; - this->PointSizeChanged(); + emit this->PointSizeChanged(); this->dataPtr->PublishMarkers(); } } // namespace gz::gui::plugins diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index cbcf4ce9f..25fec4f8d 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -95,7 +95,7 @@ void Publisher::OnPublish(const bool _checked) if (this->dataPtr->timer != nullptr) { this->dataPtr->timer->stop(); - this->disconnect(this->dataPtr->timer, 0, 0, 0); + disconnect(this->dataPtr->timer, nullptr, nullptr, nullptr); } this->dataPtr->pub = transport::Node::Publisher(); return; @@ -107,7 +107,7 @@ void Publisher::OnPublish(const bool _checked) // Check it's possible to create message auto msg = msgs::Factory::New(msgType, msgData); - if (!msg || (msg->DebugString() == "" && msgData != "")) + if (!msg || (msg->DebugString().empty() && !msgData.empty())) { gzerr << "Unable to create message of type[" << msgType << "] " << "with data[" << msgData << "].\n"; @@ -135,7 +135,7 @@ void Publisher::OnPublish(const bool _checked) } this->dataPtr->timer->setInterval(1000/this->dataPtr->frequency); - this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() + connect(this->dataPtr->timer, &QTimer::timeout, this->dataPtr->timer, [=]() { auto newMsg = msgs::Factory::New(msgType, msgData); this->dataPtr->pub.Publish(*newMsg); @@ -153,7 +153,7 @@ QString Publisher::MsgType() const void Publisher::SetMsgType(const QString &_msgType) { this->dataPtr->msgType = _msgType; - this->MsgTypeChanged(); + emit this->MsgTypeChanged(); } ///////////////////////////////////////////////// @@ -166,7 +166,7 @@ QString Publisher::MsgData() const void Publisher::SetMsgData(const QString &_msgData) { this->dataPtr->msgData = _msgData; - this->MsgDataChanged(); + emit this->MsgDataChanged(); } ///////////////////////////////////////////////// @@ -179,7 +179,7 @@ QString Publisher::Topic() const void Publisher::SetTopic(const QString &_topic) { this->dataPtr->topic = _topic; - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// @@ -192,7 +192,7 @@ double Publisher::Frequency() const void Publisher::SetFrequency(const double _frequency) { this->dataPtr->frequency = _frequency; - this->FrequencyChanged(); + emit this->FrequencyChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/screenshot/Screenshot.cc index a14387516..9d5ab6dcd 100644 --- a/src/plugins/screenshot/Screenshot.cc +++ b/src/plugins/screenshot/Screenshot.cc @@ -79,8 +79,6 @@ Screenshot::Screenshot() this->dataPtr->directory = defaultDir; } } - - this->DirectoryChanged(); } ///////////////////////////////////////////////// @@ -155,7 +153,7 @@ void Screenshot::SaveScreenshot() this->SetSavedScreenshotPath(QString::fromStdString(savePath)); - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Saved image to: " + savePath + ""), 4000); } @@ -199,7 +197,7 @@ void Screenshot::SetDirectory(const QString &_dirUrl) { QString newDir = QUrl(_dirUrl).toLocalFile(); this->dataPtr->directory = newDir.toStdString(); - this->DirectoryChanged(); + emit this->DirectoryChanged(); } ///////////////////////////////////////////////// @@ -212,8 +210,8 @@ QString Screenshot::SavedScreenshotPath() const void Screenshot::SetSavedScreenshotPath(const QString &_filename) { this->dataPtr->savedScreenshotPath = _filename; - this->SavedScreenshotPathChanged(); - this->savedScreenshot(); + emit this->SavedScreenshotPathChanged(); + emit this->savedScreenshot(); } } // namespace gz::gui::plugins diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/tape_measure/TapeMeasure.cc index d5d5736d7..99a60c584 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -149,7 +149,7 @@ void TapeMeasure::Reset() this->dataPtr->endPoint = gz::math::Vector3d::Zero; this->dataPtr->distance = 0.0; this->dataPtr->measure = false; - this->newDistance(); + emit this->newDistance(); QGuiApplication::restoreOverrideCursor(); // Notify 3D scene that we are done using the right click, so it can @@ -247,7 +247,7 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) this->DrawLine(this->dataPtr->kLineId, this->dataPtr->startPoint, point, this->dataPtr->hoverColor); this->dataPtr->distance = this->dataPtr->startPoint.Distance(point); - this->newDistance(); + emit this->newDistance(); } } } @@ -278,7 +278,7 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) this->dataPtr->endPoint, this->dataPtr->drawColor); this->dataPtr->distance = this->dataPtr->startPoint.Distance(this->dataPtr->endPoint); - this->newDistance(); + emit this->newDistance(); QGuiApplication::restoreOverrideCursor(); // Notify 3D scene that we are done using the right click, so it can diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/teleop/Teleop.cc index ccc12f6ac..d17127515 100644 --- a/src/plugins/teleop/Teleop.cc +++ b/src/plugins/teleop/Teleop.cc @@ -168,7 +168,7 @@ void Teleop::SetTopic(const QString &_topic) (this->dataPtr->topic); if (!this->dataPtr->cmdVelPub) { - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Error when advertising topic: " + this->dataPtr->topic), 4000); gzerr << "Error when advertising topic: " << @@ -176,18 +176,18 @@ void Teleop::SetTopic(const QString &_topic) } else { - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Advertising topic: '" + this->dataPtr->topic + "'"), 4000); } - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// void Teleop::SetMaxForwardVel(double _velocity) { this->dataPtr->maxForwardVel = _velocity; - this->MaxForwardVelChanged(); + emit this->MaxForwardVelChanged(); } ///////////////////////////////////////////////// @@ -200,7 +200,7 @@ double Teleop::MaxForwardVel() const void Teleop::SetMaxVerticalVel(double _velocity) { this->dataPtr->maxVerticalVel = _velocity; - this->MaxVerticalVelChanged(); + emit this->MaxVerticalVelChanged(); } ///////////////////////////////////////////////// @@ -213,7 +213,7 @@ double Teleop::MaxVerticalVel() const void Teleop::SetMaxYawVel(double _velocity) { this->dataPtr->maxYawVel = _velocity; - this->MaxYawVelChanged(); + emit this->MaxYawVelChanged(); } ///////////////////////////////////////////////// diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/topic_echo/TopicEcho.cc index e91c28478..eb6547c13 100644 --- a/src/plugins/topic_echo/TopicEcho.cc +++ b/src/plugins/topic_echo/TopicEcho.cc @@ -110,7 +110,7 @@ void TopicEcho::OnMessage(const google::protobuf::Message &_msg) std::lock_guard lock(this->dataPtr->mutex); - this->AddMsg(QString::fromStdString(_msg.DebugString())); + emit this->AddMsg(QString::fromStdString(_msg.DebugString())); } ///////////////////////////////////////////////// @@ -142,7 +142,7 @@ QString TopicEcho::Topic() const void TopicEcho::SetTopic(const QString &_topic) { this->dataPtr->topic = _topic; - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// @@ -162,7 +162,7 @@ bool TopicEcho::Paused() const void TopicEcho::SetPaused(const bool &_paused) { this->dataPtr->paused = _paused; - this->PausedChanged(); + emit this->PausedChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/topic_echo/TopicEcho_TEST.cc index d91249bdd..edb746589 100644 --- a/src/plugins/topic_echo/TopicEcho_TEST.cc +++ b/src/plugins/topic_echo/TopicEcho_TEST.cc @@ -139,7 +139,7 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) // Check message was echoed ASSERT_EQ(msgStringList->rowCount(), 1); - EXPECT_EQ(msgStringList->stringList()[0].toStdString(), + EXPECT_EQ(msgStringList->stringList().at(0).toStdString(), "data: \"example string\"\n"); // Publish more than buffer size (messages numbered 0 to 14) @@ -210,9 +210,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ASSERT_EQ(msgStringList->rowCount(), 11); // The last one is guaranteed to be the new message - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Pause plugin->SetPaused(true); @@ -232,9 +232,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ++sleep; } ASSERT_EQ(msgStringList->rowCount(), 11); - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Decrease buffer bufferField->setProperty("value", 5); @@ -260,9 +260,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ASSERT_EQ(msgStringList->rowCount(), 5); // The last message is still the new one - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message 2\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Stop echoing plugin->OnEcho(false); diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index edbecae45..96bb042f5 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -409,14 +409,14 @@ void TopicViewer::UpdateModel() } // remove the topics that don't exist in the network - for (auto topic : topicsToRemove) + for (const auto &topic : topicsToRemove) { - auto root = this->dataPtr->model->invisibleRootItem(); + auto *root = this->dataPtr->model->invisibleRootItem(); // search for the topic in the model for (int i = 0; i < root->rowCount(); ++i) { - auto child = root->child(i); + auto *child = root->child(i); if (child->data(NAME_ROLE).toString().toStdString() == topic.first && child->data(TYPE_ROLE).toString().toStdString() == topic.second) diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index 86095179c..ebdc0f54b 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -153,7 +153,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) << "]" << std::endl; // Play / pause buttons - if (auto playElem = _pluginElem->FirstChildElement("play_pause")) + if (const auto *playElem = _pluginElem->FirstChildElement("play_pause")) { auto has = false; playElem->QueryBoolText(&has); @@ -162,21 +162,21 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) if (has) { auto startPaused = this->dataPtr->pause; - if (auto pausedElem = _pluginElem->FirstChildElement("start_paused")) + if (const auto *pausedElem = _pluginElem->FirstChildElement("start_paused")) { pausedElem->QueryBoolText(&startPaused); } this->dataPtr->pause = startPaused; this->dataPtr->lastStatsMsgPaused = startPaused; if (startPaused) - this->paused(); + emit this->paused(); else - this->playing(); + emit this->playing(); } } // Step buttons - if (auto stepElem = _pluginElem->FirstChildElement("step")) + if (const auto *stepElem = _pluginElem->FirstChildElement("step")) { auto has = false; stepElem->QueryBoolText(&has); @@ -185,7 +185,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) // Subscribe to world stats std::string statsTopic; - auto statsTopicElem = _pluginElem->FirstChildElement("stats_topic"); + const auto *statsTopicElem = _pluginElem->FirstChildElement("stats_topic"); if (nullptr != statsTopicElem && nullptr != statsTopicElem->GetText()) statsTopic = statsTopicElem->GetText(); @@ -230,7 +230,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) << std::endl; } - if (auto elem = _pluginElem->FirstChildElement("use_event")) + if (const auto *elem = _pluginElem->FirstChildElement("use_event")) elem->QueryBoolText(&this->dataPtr->useEvent); if (this->dataPtr->useEvent) @@ -261,10 +261,10 @@ void WorldControl::ProcessMsg() // this plugin has been registered by the server if (this->dataPtr->msg.paused() && (!this->dataPtr->pause || !this->dataPtr->lastStatsMsgPaused)) - this->paused(); + emit this->paused(); else if (!this->dataPtr->msg.paused() && (this->dataPtr->pause || this->dataPtr->lastStatsMsgPaused)) - this->playing(); + emit this->playing(); this->dataPtr->pause = this->dataPtr->msg.paused(); this->dataPtr->lastStatsMsgPaused = this->dataPtr->msg.paused(); @@ -302,7 +302,7 @@ void WorldControl::OnPause() void WorldControl::OnReset() { msgs::WorldControl msg; - auto msgReset = new msgs::WorldReset(); + auto *msgReset = new msgs::WorldReset(); msgReset->set_all(true); msg.set_pause(true); msg.set_allocated_reset(msgReset); diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index 96c2ecead..7fdae646f 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -288,7 +288,7 @@ QString WorldStats::RealTimeFactor() const void WorldStats::SetRealTimeFactor(const QString &_realTimeFactor) { this->dataPtr->realTimeFactor = _realTimeFactor; - this->RealTimeFactorChanged(); + emit this->RealTimeFactorChanged(); } ///////////////////////////////////////////////// @@ -301,7 +301,7 @@ QString WorldStats::SimTime() const void WorldStats::SetSimTime(const QString &_simTime) { this->dataPtr->simTime = _simTime; - this->SimTimeChanged(); + emit this->SimTimeChanged(); } ///////////////////////////////////////////////// @@ -314,7 +314,7 @@ QString WorldStats::RealTime() const void WorldStats::SetRealTime(const QString &_realTime) { this->dataPtr->realTime = _realTime; - this->RealTimeChanged(); + emit this->RealTimeChanged(); } ///////////////////////////////////////////////// @@ -327,7 +327,7 @@ QString WorldStats::Iterations() const void WorldStats::SetIterations(const QString &_iterations) { this->dataPtr->iterations = _iterations; - this->IterationsChanged(); + emit this->IterationsChanged(); } } // namespace gz::gui::plugins diff --git a/test/integration/transport_scene_manager.cc b/test/integration/transport_scene_manager.cc index 9c71e08e2..73481e228 100644 --- a/test/integration/transport_scene_manager.cc +++ b/test/integration/transport_scene_manager.cc @@ -73,7 +73,7 @@ TEST(TransportSceneManagerTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) EXPECT_EQ(plugin->Title(), "Transport Scene Manager"); // Cleanup - for (const auto &p : plugins) + for (const auto &p : qAsConst(plugins)) { auto pluginName = p->CardItem()->objectName().toStdString(); EXPECT_TRUE(app.RemovePlugin(pluginName));