Skip to content

Commit

Permalink
Fix segfault in GpuRays with multiple reloads
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Aug 12, 2022
1 parent 9e05963 commit f604212
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ogre/src/OgreGpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include <gz/common/Mesh.hh>
#include <gz/common/MeshManager.hh>
#include <gz/common/SubMesh.hh>

#include <gz/math/Color.hh>
Expand Down Expand Up @@ -203,6 +202,12 @@ void OgreGpuRays::Destroy()
this->dataPtr->orthoCam = nullptr;
}

if (this->dataPtr->undistMesh)
{
delete this->dataPtr->undistMesh;
this->dataPtr->undistMesh = nullptr;
}

this->dataPtr->visual.reset();
this->dataPtr->texIdx.clear();
this->dataPtr->texCount = 0u;
Expand Down Expand Up @@ -886,8 +891,6 @@ void OgreGpuRays::CreateMesh()
mesh->AddSubMesh(*submesh);

this->dataPtr->undistMesh = mesh;

common::MeshManager::Instance()->AddMesh(this->dataPtr->undistMesh);
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit f604212

Please sign in to comment.