Fixed crash by double-freeing a (shared) pointer.

Fixed memory leak by only adding the physical body
for exact shapes once.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11009 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2012-03-22 00:20:19 +00:00
parent 8a0e792d53
commit c078df7e18

View File

@@ -228,7 +228,7 @@ void ThreeDAnimation::createPhysicsBody(const std::string &shape)
}
}
} // for i<getMeshBufferCount
triangle_mesh->createPhysicalBody();
triangle_mesh->createCollisionShape();
m_collision_shape = &triangle_mesh->getCollisionShape();
m_triangle_mesh = triangle_mesh;
}
@@ -263,7 +263,12 @@ ThreeDAnimation::~ThreeDAnimation()
World::getWorld()->getPhysics()->removeBody(m_body);
delete m_body;
delete m_motion_state;
delete m_collision_shape;
// If an exact shape was used, the collision shape pointer
// here is a copy of the collision shape pointer in the
// triangle mesh. In order to avoid double-freeing this
// pointer, we don't free the pointer in this case.
if(!m_triangle_mesh)
delete m_collision_shape;
}
if (m_triangle_mesh)