Skip to content

Commit

Permalink
Fix MeshShape::clear() for safer mesh removal (#3164)
Browse files Browse the repository at this point in the history
Added a check to retrieve the mesh by name before attempting to remove it.

(cherry picked from commit f91a650)
  • Loading branch information
scmwang authored and mergify[bot] committed Dec 16, 2024
1 parent e94c891 commit 8fb3bbc
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8fb3bbc

Please sign in to comment.