diff --git a/gazebo/transport/ConnectionManager.cc b/gazebo/transport/ConnectionManager.cc index 55641eea1c..8920b74e33 100644 --- a/gazebo/transport/ConnectionManager.cc +++ b/gazebo/transport/ConnectionManager.cc @@ -215,6 +215,9 @@ void ConnectionManager::Fini() return; this->Stop(); + if (this->initialized) + while (this->stopped == false) + common::Time::MSleep(100); if (this->masterConn) { @@ -244,10 +247,6 @@ void ConnectionManager::Fini() void ConnectionManager::Stop() { this->stop = true; - this->updateCondition.notify_all(); - if (this->initialized) - while (this->stopped == false) - common::Time::MSleep(100); } ////////////////////////////////////////////////// diff --git a/plugins/DepthCameraPlugin.cc b/plugins/DepthCameraPlugin.cc index aa71dd8429..a42cec6dbb 100644 --- a/plugins/DepthCameraPlugin.cc +++ b/plugins/DepthCameraPlugin.cc @@ -16,16 +16,20 @@ */ #include +#include +#include #include "plugins/DepthCameraPlugin.hh" using namespace gazebo; GZ_REGISTER_SENSOR_PLUGIN(DepthCameraPlugin) +std::mutex global_maps_mutex; + // Added this map to avoid breaking the ABI -static std::map +static std::unordered_map connection_reflectance_map; -static std::map +static std::unordered_map connection_normals_map; ///////////////////////////////////////////////// DepthCameraPlugin::DepthCameraPlugin() @@ -40,13 +44,9 @@ DepthCameraPlugin::~DepthCameraPlugin() this->newRGBPointCloudConnection.reset(); this->newImageFrameConnection.reset(); - std::map::iterator it; - it = connection_reflectance_map.find(this); - it->second.reset(); - connection_reflectance_map.erase(it); - it = connection_normals_map.find(this); - it->second.reset(); - connection_normals_map.erase(it); + std::lock_guard guard{global_maps_mutex}; + connection_reflectance_map.erase(this); + connection_normals_map.erase(this); this->parentSensor.reset(); this->depthCamera.reset(); @@ -93,6 +93,7 @@ void DepthCameraPlugin::Load(sensors::SensorPtr _sensor, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + std::lock_guard guard{global_maps_mutex}; connection_reflectance_map. insert(std::pair (this, newReflectanceFrameConnection)); diff --git a/test/integration/ogre_log.cc b/test/integration/ogre_log.cc index 15b751297d..ab68c952ff 100644 --- a/test/integration/ogre_log.cc +++ b/test/integration/ogre_log.cc @@ -65,9 +65,20 @@ TEST_F(OgreLog, LogError) if (line.find(" GL_EXTENSIONS =") < 12) continue; - EXPECT_EQ(line.find("Error"), std::string::npos); - EXPECT_EQ(line.find("error"), std::string::npos); - EXPECT_EQ(line.find("ERROR"), std::string::npos); + // A GLX extension may have the word "error" in its name. For example: + // GLX_ARB_create_context_no_error. + // We will skip the line that lists all the extensions. This line starts + // with a date, so we just check that "Supported GLX extensions:" is + // toward the beginning. + // False positive cppcheck + // https://sourceforge.net/p/cppcheck/discussion/general/thread/0c113d65/ + // cppcheck-suppress stlIfStrFind + if (line.find(" Supported GLX extensions: ") < 12) + continue; + + EXPECT_EQ(line.find("Error"), std::string::npos) << line; + EXPECT_EQ(line.find("error"), std::string::npos) << line; + EXPECT_EQ(line.find("ERROR"), std::string::npos) << line; } }