Fixed more memory leaks.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5674 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-07-08 23:03:45 +00:00
parent e8d97d035d
commit 09fbb5f0ff
4 changed files with 26 additions and 4 deletions

View File

@ -55,6 +55,8 @@ QuadGraph::~QuadGraph()
for(unsigned int i=0; i<m_all_nodes.size(); i++) {
delete m_all_nodes[i];
}
if(UserConfigParams::m_track_debug)
cleanupDebugMesh();
} // ~QuadGraph
// -----------------------------------------------------------------------------
@ -276,7 +278,7 @@ void QuadGraph::createDebugMesh()
c.setBlue(i%2 ? 0 : 255);
v[i].Color = c;
}
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh);
} // createDebugMesh
// -----------------------------------------------------------------------------
@ -285,7 +287,11 @@ void QuadGraph::createDebugMesh()
void QuadGraph::cleanupDebugMesh()
{
irr_driver->removeNode(m_node);
irr_driver->removeMesh(m_mesh);
m_node = NULL;
// No need to call irr_driber->removeMesh, since the mesh
// was manually made and so never added to the mesh cache.
m_mesh->drop();
m_mesh = NULL;
} // cleanupDebugMesh
// -----------------------------------------------------------------------------

View File

@ -32,6 +32,18 @@ QuadSet::QuadSet(const std::string& filename) {
load(filename);
} // QuadSet
// -----------------------------------------------------------------------------
/** Destructor, frees all memory.
*/
QuadSet::~QuadSet()
{
for(unsigned int i=0; i<m_all_quads.size(); i++)
{
delete m_all_quads[i];
}
m_all_quads.clear();
} // ~QuadSet
// -----------------------------------------------------------------------------
/** This function interprets a point specification as an attribute in the
xml quadset file. It understands two different specifications:

View File

@ -47,6 +47,7 @@ public:
static const int QUAD_NONE=-1;
QuadSet (const std::string& filename);
~QuadSet ();
int getCurrentQuad(const Vec3& p, int oldQuad) const;
const Quad& getQuad(int n) const {return *(m_all_quads[n]); }

View File

@ -118,8 +118,11 @@ void Track::reset()
*/
void Track::cleanup()
{
if(UserConfigParams::m_track_debug)
m_quad_graph->cleanupDebugMesh();
if(m_quad_graph)
{
delete m_quad_graph;
m_quad_graph = NULL;
}
item_manager->cleanup();
for(unsigned int i=0; i<m_animated_textures.size(); i++)