Profile courses may refer to profile steps, so free profile courses first.

This commit is contained in:
Glenn Maynard
2007-01-19 06:36:49 +00:00
parent c147dd5a42
commit 58bb20d6b3
+4 -3
View File
@@ -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<Course*> 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();
}