fix crash on exiting editor

clean up invalidation of Song and Courses
This commit is contained in:
Chris Danford
2004-08-12 04:49:15 +00:00
parent cbe80105fb
commit 873c148f0e
7 changed files with 35 additions and 22 deletions
+10 -12
View File
@@ -8,7 +8,6 @@
#include "RageSoundReader_FileReader.h"
#include "RageSurface_Load.h"
#include "RageException.h"
#include "SongManager.h"
#include "SongCacheIndex.h"
#include "GameManager.h"
#include "PrefsManager.h"
@@ -78,29 +77,28 @@ Song::Song()
Song::~Song()
{
for( unsigned i=0; i<m_vpSteps.size(); i++ )
SAFE_DELETE( m_vpSteps[i] );
FOREACH( Steps*, m_vpSteps, s )
SAFE_DELETE( *s );
m_vpSteps.clear();
/* We deleted some Steps*; clear stuff that used it. */
/* TODO: Don't make Song depend on SongManager. This is breaking
* encapsulation and placing confusing limitation on what can be done in
* SONGMAN->Invalidate(). -Chris */
SONGMAN->Invalidate( this );
// It's the responsibility of the owner of this Song to make sure
// that all pointers to this Song and its Steps are invalidated.
}
/* Reset to an empty song. */
void Song::Reset()
{
for( unsigned i=0; i<m_vpSteps.size(); i++ )
SAFE_DELETE( m_vpSteps[i] );
FOREACH( Steps*, m_vpSteps, s )
SAFE_DELETE( *s );
m_vpSteps.clear();
FOREACH_StepsType( st )
m_vpStepsByType[st].clear();
Song empty;
*this = empty;
// It's the responsibility of the owner of this Song to make sure
// that all pointers to this Song and its Steps are invalidated.
}