Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed unneeded plugin update #944

Merged
merged 5 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/ignition/gazebo/gui/GuiRunner.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
chapulina marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
4 changes: 0 additions & 4 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ std::unique_ptr<ignition::gui::Application> 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());

Expand Down Expand Up @@ -214,8 +212,6 @@ std::unique_ptr<ignition::gui::Application> 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;

Expand Down
19 changes: 3 additions & 16 deletions src/gui/GuiRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<GuiSystem *>(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.
}

/////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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));
Expand All @@ -217,4 +233,3 @@ TEST_F(JointPositionControllerGui,
// Cleanup
plugins.clear();
}

2 changes: 0 additions & 2 deletions src/gui/plugins/plot_3d/Plot3D_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down