From 06184b29b4f867a48a26c9e6cadfe362eb2f19ce Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:44:33 -0500 Subject: [PATCH] Fix MeshShape::clear() for safer mesh removal (#3164) (#3166) Co-authored-by: Matt Wang --- .../rviz_plugin_render_tools/src/mesh_shape.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/src/mesh_shape.cpp b/moveit_ros/visualization/rviz_plugin_render_tools/src/mesh_shape.cpp index 40afa630c6..194584f88e 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/src/mesh_shape.cpp +++ b/moveit_ros/visualization/rviz_plugin_render_tools/src/mesh_shape.cpp @@ -140,7 +140,11 @@ void MeshShape::clear() if (entity_) { entity_->detachFromParent(); - Ogre::MeshManager::getSingleton().remove(entity_->getMesh()->getName()); + const auto& mesh_name = entity_->getMesh()->getName(); + if (Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().getByName(mesh_name)) + { + Ogre::MeshManager::getSingleton().remove(mesh); + } scene_manager_->destroyEntity(entity_); entity_ = nullptr; }