Fixed various memory leaks.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3857 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-08-13 23:26:38 +00:00
parent 7a84273ec5
commit 405ee12ca5
4 changed files with 18 additions and 1 deletions

View File

@ -56,7 +56,8 @@ Camera::Camera(int camera_index, const Kart* kart)
// ----------------------------------------------------------------------------
Camera::~Camera()
{
reset();
irr_driver->removeCamera(m_camera);
m_camera=NULL;
}
// ----------------------------------------------------------------------------

View File

@ -522,6 +522,20 @@ scene::ICameraSceneNode *IrrDriver::addCamera()
return m_scene_manager->addCameraSceneNode();
} // addCamera
// ----------------------------------------------------------------------------
/** Removes a camera. This can't be done with removeNode() since the camera
* can be marked as active, meaning a drop will not delete it. While this
* doesn't really cause a memory leak (the camera is removed the next time
* a camera is added), it's a bit cleaner and easier to check for memory
* leaks, since the scene root should now always be empty.
*/
void IrrDriver::removeCamera(scene::ICameraSceneNode *camera)
{
if(camera==m_scene_manager->getActiveCamera())
m_scene_manager->setActiveCamera(NULL); // basically causes a drop
camera->remove();
} // removeCamera
// ----------------------------------------------------------------------------
/** Loads a texture from a file and returns the texture object.
* \param filename File name of the texture to load.

View File

@ -104,6 +104,7 @@ public:
*addAnimatedMesh(scene::IAnimatedMesh *mesh);
scene::ICameraSceneNode
*addCamera();
void removeCamera(scene::ICameraSceneNode *camera);
void update(float dt);
void changeResolution();

View File

@ -448,6 +448,7 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2di &dimension,
camera->setTarget(core::vector3df(center.getX(),0,center.getY()));
video::ITexture *texture=irr_driver->endRenderToTexture();
cleanupDebugMesh();
irr_driver->removeCamera(camera);
m_min_coord = bb_min;
m_scaling.setX(dimension.Width/(bb_max.getX()-bb_min.getX()));
m_scaling.setY(dimension.Width/(bb_max.getY()-bb_min.getY()));