Fix leak by introducing code to free meshes that are not associated to any scene node
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10774 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b950d4a7bc
commit
27360fbe93
@ -195,6 +195,14 @@ void Track::cleanup()
|
||||
}
|
||||
m_all_cached_meshes.clear();
|
||||
|
||||
// Now free meshes that are not associated to any scene node.
|
||||
for (unsigned int i=0; i<m_detached_cached_meshes.size(); i++)
|
||||
{
|
||||
irr_driver->dropAllTextures(m_detached_cached_meshes[i]);
|
||||
irr_driver->removeMeshFromCache(m_detached_cached_meshes[i]);
|
||||
}
|
||||
m_detached_cached_meshes.clear();
|
||||
|
||||
QuadGraph::destroy();
|
||||
if(m_check_manager) delete m_check_manager;
|
||||
if(m_mini_map)
|
||||
@ -821,6 +829,13 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
|
||||
scene::IMesh* original_mesh = irr_driver->getMesh(full_path);
|
||||
|
||||
if (std::find(m_detached_cached_meshes.begin(),
|
||||
m_detached_cached_meshes.end(),
|
||||
original_mesh) == m_detached_cached_meshes.end())
|
||||
{
|
||||
m_detached_cached_meshes.push_back(original_mesh);
|
||||
}
|
||||
|
||||
// create a node out of this mesh just for bullet; delete it after, normal maps are special
|
||||
// and require tangent meshes
|
||||
scene_node = irr_driver->addMesh(original_mesh);
|
||||
@ -836,6 +851,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
scene::IMesh* mesh = manip->createMeshWithTangents(original_mesh);
|
||||
mesh->grab();
|
||||
irr_driver->grabAllTextures(mesh);
|
||||
|
||||
m_all_cached_meshes.push_back(mesh);
|
||||
scene_node = irr_driver->addMesh(mesh);
|
||||
scene_node->setPosition(xyz);
|
||||
|
@ -136,6 +136,12 @@ private:
|
||||
* that those meshes are being cached by irrlicht, and need to be freed. */
|
||||
std::vector<scene::IMesh*> m_all_cached_meshes;
|
||||
|
||||
/**
|
||||
* m_all_cached_meshes assumes meshes are attached to a scene node.
|
||||
* This one assumes the mesh is NOT connected to any node.
|
||||
*/
|
||||
std::vector<scene::IMesh*> m_detached_cached_meshes;
|
||||
|
||||
/** A list of all textures loaded by the track, so that they can
|
||||
* be removed from the cache at cleanup time. */
|
||||
std::vector<video::ITexture*> m_all_cached_textures;
|
||||
|
Loading…
x
Reference in New Issue
Block a user