Make sure that music pointers are always null when deleted
This commit is contained in:
parent
9681a9586f
commit
04cc5bb62c
@ -145,10 +145,23 @@ void MusicInformation::startMusic()
|
|||||||
m_time_since_faster = 0.0f;
|
m_time_since_faster = 0.0f;
|
||||||
m_mode = SOUND_NORMAL;
|
m_mode = SOUND_NORMAL;
|
||||||
|
|
||||||
if (m_normal_filename== "") return;
|
if (m_normal_music)
|
||||||
|
{
|
||||||
|
delete m_normal_music;
|
||||||
|
m_normal_music = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_fast_music)
|
||||||
|
{
|
||||||
|
delete m_fast_music;
|
||||||
|
m_fast_music = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// First load the 'normal' music
|
// First load the 'normal' music
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
if (m_normal_filename.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (StringUtils::getExtension(m_normal_filename) != "ogg")
|
if (StringUtils::getExtension(m_normal_filename) != "ogg")
|
||||||
{
|
{
|
||||||
Log::warn("MusicInformation", "Music file %s is not found or file "
|
Log::warn("MusicInformation", "Music file %s is not found or file "
|
||||||
@ -156,15 +169,13 @@ void MusicInformation::startMusic()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_normal_music) delete m_normal_music;
|
|
||||||
|
|
||||||
#if HAVE_OGGVORBIS
|
#if HAVE_OGGVORBIS
|
||||||
m_normal_music = new MusicOggStream(m_normal_loop_start);
|
m_normal_music = new MusicOggStream(m_normal_loop_start);
|
||||||
#else
|
#else
|
||||||
m_normal_music = new MusicDummy();
|
m_normal_music = new MusicDummy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((m_normal_music->load(m_normal_filename)) == false)
|
if (m_normal_music->load(m_normal_filename) == false)
|
||||||
{
|
{
|
||||||
delete m_normal_music;
|
delete m_normal_music;
|
||||||
m_normal_music = NULL;
|
m_normal_music = NULL;
|
||||||
@ -178,18 +189,14 @@ void MusicInformation::startMusic()
|
|||||||
|
|
||||||
// Then (if available) load the music for the last track
|
// Then (if available) load the music for the last track
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
if (m_fast_music) delete m_fast_music;
|
if (m_fast_filename.empty())
|
||||||
if (m_fast_filename == "")
|
return;
|
||||||
|
|
||||||
|
if (StringUtils::getExtension(m_fast_filename) != "ogg")
|
||||||
{
|
{
|
||||||
m_fast_music = NULL;
|
Log::warn("MusicInformation",
|
||||||
return; // no fast music
|
"Music file %s format not recognized, fast music is ignored",
|
||||||
}
|
m_fast_filename.c_str());
|
||||||
|
|
||||||
if(StringUtils::getExtension(m_fast_filename)!="ogg")
|
|
||||||
{
|
|
||||||
Log::warn(
|
|
||||||
"Music file %s format not recognized, fast music is ignored",
|
|
||||||
m_fast_filename.c_str());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,10 +206,10 @@ void MusicInformation::startMusic()
|
|||||||
m_fast_music = new MusicDummy();
|
m_fast_music = new MusicDummy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((m_fast_music->load(m_fast_filename)) == false)
|
if (m_fast_music->load(m_fast_filename) == false)
|
||||||
{
|
{
|
||||||
delete m_fast_music;
|
delete m_fast_music;
|
||||||
m_fast_music=0;
|
m_fast_music = NULL;
|
||||||
Log::warn("MusicInformation", "Unabled to load fast music %s, not "
|
Log::warn("MusicInformation", "Unabled to load fast music %s, not "
|
||||||
"supported or not found.\n", m_fast_filename.c_str());
|
"supported or not found.\n", m_fast_filename.c_str());
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user