Fixed title music memory leak.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2638 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
stevo14 2008-12-12 16:47:07 +00:00
parent b017c0aefd
commit 7def11135d
2 changed files with 6 additions and 9 deletions

View File

@ -52,16 +52,9 @@ MusicOggStream::~MusicOggStream()
bool MusicOggStream::load(const std::string& filename)
{
m_error = true;
if(!release())
{
user_config->setMusic(UserConfig::UC_TEMPORARY_DISABLE);
fprintf(stderr,"Problems oggStream:release. Disabling music.\n");
return false;
}
m_fileName = filename;
if(m_fileName=="") return false;
if(m_fileName=="") return false;
m_oggFile = fopen(m_fileName.c_str(), "rb");
if(!m_oggFile)

View File

@ -137,6 +137,10 @@ void SoundManager::addMusicToTracks()
//-----------------------------------------------------------------------------
void SoundManager::startMusic(MusicInformation* mi)
{
// It is possible here that startMusic() will be called without first calling stopMusic().
// This would cause a memory leak by overwriting m_current_music without first releasing it's resources.
// Guard against this here by making sure that stopMusic() is called before starting new music.
stopMusic();
m_current_music = mi;
if(!mi || !user_config->doMusic() || !m_initialized) return;