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:
parent
b017c0aefd
commit
7def11135d
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user