From: <au...@us...> - 2010-11-15 18:41:17
|
Revision: 6573 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6573&view=rev Author: auria Date: 2010-11-15 18:41:11 +0000 (Mon, 15 Nov 2010) Log Message: ----------- Don't crash when music not found Modified Paths: -------------- main/trunk/src/states_screens/grand_prix_lose.cpp main/trunk/src/states_screens/grand_prix_win.cpp main/trunk/src/tracks/track.cpp Modified: main/trunk/src/states_screens/grand_prix_lose.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_lose.cpp 2010-11-15 11:11:28 UTC (rev 6572) +++ main/trunk/src/states_screens/grand_prix_lose.cpp 2010-11-15 18:41:11 UTC (rev 6573) @@ -56,7 +56,15 @@ m_throttle_FPS = false; - m_music = music_manager->getMusicInformation(file_manager->getMusicFile("lose_theme.music")); + try + { + m_music = music_manager->getMusicInformation(file_manager->getMusicFile("lose_theme.music")); + } + catch (std::exception& e) + { + fprintf(stderr, "%s", e.what()); + m_music = NULL; + } } // GrandPrixLose // ------------------------------------------------------------------------------------- @@ -74,7 +82,6 @@ void GrandPrixLose::init() { Screen::init(); - //music_manager->startMusic(music_manager->getMusicInformation(file_manager->getMusicFile("lose_theme.music"))); m_phase = 1; m_sky_angle = 0.0f; Modified: main/trunk/src/states_screens/grand_prix_win.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_win.cpp 2010-11-15 11:11:28 UTC (rev 6572) +++ main/trunk/src/states_screens/grand_prix_win.cpp 2010-11-15 18:41:11 UTC (rev 6573) @@ -37,7 +37,15 @@ m_throttle_FPS = false; - m_music = music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music")); + try + { + m_music = music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music")); + } + catch (std::exception& e) + { + fprintf(stderr, "%s", e.what()); + m_music = NULL; + } } // GrandPrixWin // ------------------------------------------------------------------------------------- @@ -130,8 +138,6 @@ unlocked_label->add(); } - - //music_manager->startMusic(music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music"))); m_phase = 1; m_sky_angle = 0.0f; Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-11-15 11:11:28 UTC (rev 6572) +++ main/trunk/src/tracks/track.cpp 2010-11-15 18:41:11 UTC (rev 6573) @@ -263,18 +263,26 @@ } if(!mi) { - std::string shared_name = file_manager->getMusicFile(filenames[i]); - if(shared_name!="") + try { - try + std::string shared_name = file_manager->getMusicFile(filenames[i]); + if(shared_name!="") { - mi = music_manager->getMusicInformation(shared_name); - } - catch(std::runtime_error) - { - mi = NULL; - } - } // shared_name!="" + try + { + mi = music_manager->getMusicInformation(shared_name); + } + catch(std::runtime_error) + { + mi = NULL; + } + } // shared_name!="" + } + catch (std::exception& e) + { + mi = NULL; + } + } if(!mi) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |