From 58bb20d6b389e51b187164eca70eea3bab053f26 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 19 Jan 2007 06:36:49 +0000 Subject: [PATCH] Profile courses may refer to profile steps, so free profile courses first. --- stepmania/src/SongManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index fa31ce7334..da8ef37482 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -1599,9 +1599,7 @@ int SongManager::GetNumEditsLoadedFromProfile( ProfileSlot slot ) const void SongManager::FreeAllLoadedFromProfile( ProfileSlot slot ) { - FOREACH( Song*, m_pSongs, s ) - (*s)->FreeAllLoadedFromProfile( slot ); - + /* Profile courses may refer to profile steps, so free profile courses first. */ vector apToDelete; FOREACH( Course*, m_pCourses, c ) { @@ -1617,6 +1615,9 @@ void SongManager::FreeAllLoadedFromProfile( ProfileSlot slot ) for( unsigned i = 0; i < apToDelete.size(); ++i ) this->DeleteCourse( apToDelete[i] ); + FOREACH( Song*, m_pSongs, s ) + (*s)->FreeAllLoadedFromProfile( slot ); + // After freeing some Steps pointers, the cache will be invalid. StepsID::ClearCache(); }