From 6eafcb9495a570e7e7d59d39921002a384ca4d72 Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 29 Jul 2021 17:51:21 -0700 Subject: [PATCH 1/4] removed unneeded plugin update Signed-off-by: Jenn Nguyen --- include/ignition/gazebo/gui/GuiRunner.hh | 4 ---- src/gui/Gui.cc | 4 ---- src/gui/GuiRunner.cc | 20 ------------------- .../JointPositionController_TEST.cc | 5 ----- 4 files changed, 33 deletions(-) diff --git a/include/ignition/gazebo/gui/GuiRunner.hh b/include/ignition/gazebo/gui/GuiRunner.hh index 4ea88aa0be..792c5a528a 100644 --- a/include/ignition/gazebo/gui/GuiRunner.hh +++ b/include/ignition/gazebo/gui/GuiRunner.hh @@ -48,10 +48,6 @@ class IGNITION_GAZEBO_VISIBLE GuiRunner : public QObject /// \brief Destructor public: ~GuiRunner() override; - /// \brief Callback when a plugin has been added. - /// \param[in] _objectName Plugin's object name. - public slots: void OnPluginAdded(const QString &_objectName); - /// \brief Make a new state request to the server. public slots: void RequestState(); diff --git a/src/gui/Gui.cc b/src/gui/Gui.cc index f3fdd9bbda..fb1e4934e6 100644 --- a/src/gui/Gui.cc +++ b/src/gui/Gui.cc @@ -176,8 +176,6 @@ std::unique_ptr createGui( // which makes it complicated to mix configurations across worlds. // We could have a way to use world-agnostic topics like Gazebo-classic's ~ auto runner = new ignition::gazebo::GuiRunner(worldsMsg.data(0)); - runner->connect(app.get(), &ignition::gui::Application::PluginAdded, runner, - &ignition::gazebo::GuiRunner::OnPluginAdded); ++runnerCount; runner->setParent(ignition::gui::App()); @@ -214,8 +212,6 @@ std::unique_ptr createGui( // GUI runner auto runner = new ignition::gazebo::GuiRunner(worldName); - runner->connect(app.get(), &ignition::gui::Application::PluginAdded, - runner, &ignition::gazebo::GuiRunner::OnPluginAdded); runner->setParent(ignition::gui::App()); ++runnerCount; diff --git a/src/gui/GuiRunner.cc b/src/gui/GuiRunner.cc index cc5c142ff3..460713670c 100644 --- a/src/gui/GuiRunner.cc +++ b/src/gui/GuiRunner.cc @@ -102,26 +102,6 @@ void GuiRunner::RequestState() this->node.Request(this->stateTopic + "_async", req); } -///////////////////////////////////////////////// -void GuiRunner::OnPluginAdded(const QString &_objectName) -{ - auto plugin = gui::App()->PluginByName(_objectName.toStdString()); - if (!plugin) - { - ignerr << "Failed to get plugin [" << _objectName.toStdString() - << "]" << std::endl; - return; - } - - auto guiSystem = dynamic_cast(plugin.get()); - - // Do nothing for pure ign-gui plugins - if (!guiSystem) - return; - - guiSystem->Update(this->updateInfo, this->ecm); -} - ///////////////////////////////////////////////// void GuiRunner::OnStateAsyncService(const msgs::SerializedStepMap &_res) { diff --git a/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc b/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc index 2c40082982..5f85a06577 100644 --- a/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc +++ b/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc @@ -68,8 +68,6 @@ TEST_F(JointPositionControllerGui, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) // Create GUI runner to handle gazebo::gui plugins auto runner = new gazebo::GuiRunner("test"); - runner->connect(app.get(), &gui::Application::PluginAdded, - runner, &gazebo::GuiRunner::OnPluginAdded); runner->setParent(gui::App()); // Add plugin @@ -143,8 +141,6 @@ TEST_F(JointPositionControllerGui, // Create GUI runner to handle gazebo::gui plugins auto runner = new gazebo::GuiRunner("test"); - runner->connect(app.get(), &gui::Application::PluginAdded, - runner, &gazebo::GuiRunner::OnPluginAdded); runner->setParent(gui::App()); // Load plugin @@ -217,4 +213,3 @@ TEST_F(JointPositionControllerGui, // Cleanup plugins.clear(); } - From af6f6bc83392a63fc458a3074a393a9e3dd71d79 Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 29 Jul 2021 18:21:32 -0700 Subject: [PATCH 2/4] removed OnPluginAdded connection Signed-off-by: Jenn Nguyen --- src/gui/plugins/plot_3d/Plot3D_TEST.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/plugins/plot_3d/Plot3D_TEST.cc b/src/gui/plugins/plot_3d/Plot3D_TEST.cc index e84ed4abf5..f34e600409 100644 --- a/src/gui/plugins/plot_3d/Plot3D_TEST.cc +++ b/src/gui/plugins/plot_3d/Plot3D_TEST.cc @@ -74,8 +74,6 @@ TEST_F(Plot3D, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) // Create GUI runner to handle gazebo::gui plugins auto runner = new gazebo::GuiRunner("test"); - runner->connect(app.get(), &gui::Application::PluginAdded, - runner, &gazebo::GuiRunner::OnPluginAdded); runner->setParent(gui::App()); // Add plugin From 9ecc40977235ea31eb9ca1df3f73b7605c685a89 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 29 Jul 2021 19:35:37 -0700 Subject: [PATCH 3/4] Restore function for ABI Signed-off-by: Louise Poubel --- include/ignition/gazebo/gui/GuiRunner.hh | 5 +++++ src/gui/GuiRunner.cc | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/include/ignition/gazebo/gui/GuiRunner.hh b/include/ignition/gazebo/gui/GuiRunner.hh index 792c5a528a..421f49e47b 100644 --- a/include/ignition/gazebo/gui/GuiRunner.hh +++ b/include/ignition/gazebo/gui/GuiRunner.hh @@ -48,6 +48,11 @@ class IGNITION_GAZEBO_VISIBLE GuiRunner : public QObject /// \brief Destructor public: ~GuiRunner() override; + /// \brief Callback when a plugin has been added. + /// This function has no effect and is left here for ABI compatibility. + /// \param[in] _objectName Plugin's object name. + public slots: void OnPluginAdded(const QString &_objectName); + /// \brief Make a new state request to the server. public slots: void RequestState(); diff --git a/src/gui/GuiRunner.cc b/src/gui/GuiRunner.cc index 460713670c..7ca91beefc 100644 --- a/src/gui/GuiRunner.cc +++ b/src/gui/GuiRunner.cc @@ -102,6 +102,13 @@ void GuiRunner::RequestState() this->node.Request(this->stateTopic + "_async", req); } +///////////////////////////////////////////////// +void GuiRunner::OnPluginAdded(const QString &) +{ + // This function used to call Update on the plugin, but that's no longer + // necessary. The function is left here for ABI compatibility. +} + ///////////////////////////////////////////////// void GuiRunner::OnStateAsyncService(const msgs::SerializedStepMap &_res) { From 20cdc9fe57556fb763ce58dd90cad850e5700f74 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 29 Jul 2021 21:57:10 -0700 Subject: [PATCH 4/4] wait for update Signed-off-by: Louise Poubel --- .../JointPositionController_TEST.cc | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc b/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc index 5f85a06577..703fa7de84 100644 --- a/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc +++ b/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc @@ -83,6 +83,17 @@ TEST_F(JointPositionControllerGui, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) EXPECT_EQ(plugins.size(), 1); auto plugin = plugins[0]; + + int sleep = 0; + int maxSleep = 30; + while (plugin->ModelName() != "No model selected" && sleep < maxSleep) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + QCoreApplication::processEvents(); + sleep++; + } + + EXPECT_LT(sleep, maxSleep); EXPECT_EQ(plugin->Title(), "Joint position controller"); EXPECT_EQ(plugin->ModelEntity(), gazebo::kNullEntity); EXPECT_EQ(plugin->ModelName(), QString("No model selected")) @@ -171,6 +182,16 @@ TEST_F(JointPositionControllerGui, auto plugin = plugins[0]; EXPECT_EQ(plugin->Title(), "JointPositionController!"); + int sleep = 0; + int maxSleep = 30; + while (plugin->ModelName() != "No model selected" && sleep < maxSleep) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + QCoreApplication::processEvents(); + sleep++; + } + EXPECT_LT(sleep, maxSleep); + EXPECT_EQ(plugin->ModelEntity(), gazebo::kNullEntity); EXPECT_EQ(plugin->ModelName(), QString("No model selected")) << plugin->ModelName().toStdString(); @@ -192,8 +213,7 @@ TEST_F(JointPositionControllerGui, runner->RequestState(); }); - int sleep = 0; - int maxSleep = 30; + sleep = 0; while (plugin->ModelName() != "model_name" && sleep < maxSleep) { std::this_thread::sleep_for(std::chrono::milliseconds(100));