diff --git a/include/ignition/gazebo/gui/GuiRunner.hh b/include/ignition/gazebo/gui/GuiRunner.hh index 4ea88aa0be..421f49e47b 100644 --- a/include/ignition/gazebo/gui/GuiRunner.hh +++ b/include/ignition/gazebo/gui/GuiRunner.hh @@ -49,6 +49,7 @@ class IGNITION_GAZEBO_VISIBLE GuiRunner : public QObject 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); 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..7ca91beefc 100644 --- a/src/gui/GuiRunner.cc +++ b/src/gui/GuiRunner.cc @@ -103,23 +103,10 @@ void GuiRunner::RequestState() } ///////////////////////////////////////////////// -void GuiRunner::OnPluginAdded(const QString &_objectName) +void GuiRunner::OnPluginAdded(const QString &) { - 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); + // This function used to call Update on the plugin, but that's no longer + // necessary. The function is left here for ABI compatibility. } ///////////////////////////////////////////////// diff --git a/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc b/src/gui/plugins/joint_position_controller/JointPositionController_TEST.cc index 2c40082982..703fa7de84 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 @@ -85,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")) @@ -143,8 +152,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 @@ -175,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(); @@ -196,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)); @@ -217,4 +233,3 @@ TEST_F(JointPositionControllerGui, // Cleanup plugins.clear(); } - 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