Every object created in InitTuxKart() is now deleted in CleanTuxKart(). This allows (among other things) the sound managers to properly clean up OpenAL (so STK plays nice with other OpenAL apps and doesn't leak memory).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2418 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
stevo14 2008-11-07 20:42:24 +00:00
parent 1651b8bba0
commit 67569c71bc
3 changed files with 45 additions and 1 deletions

View File

@ -60,6 +60,18 @@ SFXManager::SFXManager()
//-----------------------------------------------------------------------------
SFXManager::~SFXManager()
{
//make sure there aren't any stray sfx's sitting around anywhere
for(std::vector<SFXBase*>::iterator i=m_all_sfx.begin();
i!=m_all_sfx.end(); i++)
{
delete (*i);
} // for i in m_all_sfx
//the unbuffer all of the buffers
for(unsigned int ii = 0; ii != m_sfx_buffers.size(); ii++)
{
alDeleteBuffers(1, &(m_sfx_buffers[ii]));
}
} // ~SFXManager
//----------------------------------------------------------------------------

View File

@ -79,6 +79,8 @@ SoundManager::SoundManager()
//-----------------------------------------------------------------------------
SoundManager::~SoundManager()
{
stopMusic();
if(m_initialized)
{
ALCcontext* context = alcGetCurrentContext();

View File

@ -469,6 +469,35 @@ void InitTuxkart()
grand_prix_manager->checkConsistency();
}
//=============================================================================
void CleanTuxKart()
{
//delete in reverse order of what they were created in.
//see InitTuxkart()
if(menu_manager) delete menu_manager;
if(race_manager) delete race_manager;
if(network_manager) delete network_manager;
if(grand_prix_manager) delete grand_prix_manager;
if(highscore_manager) delete highscore_manager;
if(attachment_manager) delete attachment_manager;
if(item_manager) delete item_manager;
//if(delete callback_manager) delete callback_manager; //segfaults if uncommented
if(powerup_manager) delete powerup_manager;
if(projectile_manager) delete projectile_manager;
if(kart_properties_manager) delete kart_properties_manager;
if(stk_config) delete stk_config;
if(track_manager) delete track_manager;
if(material_manager) delete material_manager;
if(history) delete history;
if(sfx_manager) delete sfx_manager;
if(sound_manager) delete sound_manager;
if(user_config) delete user_config;
if(unlock_manager) delete unlock_manager;
if(loader) delete loader;
if(translations) delete translations;
if(file_manager) delete file_manager;
}
//=============================================================================
int main(int argc, char *argv[] )
@ -601,9 +630,10 @@ int main(int argc, char *argv[] )
fclose(stdout);
}
if(highscore_manager) delete highscore_manager;
delete_fonts();
CleanTuxKart();
return 0 ;
}