From: <ik...@us...> - 2007-09-19 18:28:49
|
Revision: 1249 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=1249&view=rev Author: ikework Date: 2007-09-19 11:28:48 -0700 (Wed, 19 Sep 2007) Log Message: ----------- change ReplayPlayer -allocation/deallocation in worls, world crashed in dtor, if replay-file was not found Modified Paths: -------------- trunk/supertuxkart/src/replay_player.hpp trunk/supertuxkart/src/world.cpp Modified: trunk/supertuxkart/src/replay_player.hpp =================================================================== --- trunk/supertuxkart/src/replay_player.hpp 2007-09-19 11:03:40 UTC (rev 1248) +++ trunk/supertuxkart/src/replay_player.hpp 2007-09-19 18:28:48 UTC (rev 1249) @@ -1,4 +1,4 @@ -// $Id$ +// $Id: $ // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2007 Damien Morel <di...@fr...> @@ -25,14 +25,16 @@ #include "replay_base.hpp" -#include "replay_base.hpp" - - // class managing: // - the loading of replay-file // - the rendering of the replay (interpolation if needed) class ReplayPlayer : public ReplayBase { +public: + ReplayPlayer() : ReplayBase() {} + virtual ~ReplayPlayer() { destroy(); } + + void destroy() { ReplayBase::destroy(); } }; Modified: trunk/supertuxkart/src/world.cpp =================================================================== --- trunk/supertuxkart/src/world.cpp 2007-09-19 11:03:40 UTC (rev 1248) +++ trunk/supertuxkart/src/world.cpp 2007-09-19 18:28:48 UTC (rev 1249) @@ -208,7 +208,12 @@ #ifdef HAVE_GHOST_REPLAY m_replay_recorder.initRecorder( m_race_setup.getNumKarts() ); - if( !loadReplayHumanReadable( "test1" ) ) delete m_p_replay_player; + m_p_replay_player = new ReplayPlayer; + if( !loadReplayHumanReadable( "test1" ) ) + { + delete m_p_replay_player; + m_p_replay_player = NULL; + } #endif } @@ -243,8 +248,12 @@ #ifdef HAVE_GHOST_REPLAY m_replay_recorder.destroy(); - m_p_replay_player->destroy(); - delete m_p_replay_player; + if( m_p_replay_player ) + { + m_p_replay_player->destroy(); + delete m_p_replay_player; + m_p_replay_player = NULL; + } #endif } @@ -469,8 +478,8 @@ //----------------------------------------------------------------------------- bool World::loadReplayHumanReadable( std::string const &filename ) { - delete m_p_replay_player; - m_p_replay_player = new ReplayPlayer(); + assert( m_p_replay_player ); + m_p_replay_player->destroy(); std::string path = ReplayBase::REPLAY_FOLDER + DIR_SEPARATOR; path += filename + "."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |