fix crash, logic in deleting course edits

This commit is contained in:
Glenn Maynard
2005-08-11 20:51:15 +00:00
parent e0d81f3256
commit 89d1fae8ba
+11 -2
View File
@@ -1353,12 +1353,21 @@ void SongManager::FreeAllLoadedFromProfile( ProfileSlot slot )
FOREACH( Song*, m_pSongs, s ) FOREACH( Song*, m_pSongs, s )
(*s)->FreeAllLoadedFromProfile( slot ); (*s)->FreeAllLoadedFromProfile( slot );
vector<Course*> apToDelete;
FOREACH( Course*, m_pCourses, c ) FOREACH( Course*, m_pCourses, c )
{ {
if( (*c)->m_LoadedFromProfile == slot ) Course *pCourse = *c;
this->DeleteCourse( *c ); if( pCourse->GetLoadedFromProfileSlot() == PROFILE_SLOT_INVALID )
continue;
if( slot == PROFILE_SLOT_INVALID || pCourse->GetLoadedFromProfileSlot() == slot )
apToDelete.push_back( *c );
} }
// XXX: this will update best, etc. every time; too slow
for( unsigned i = 0; i < apToDelete.size(); ++i )
this->DeleteCourse( apToDelete[i] );
// After freeing some Steps pointers, the cache will be invalid. // After freeing some Steps pointers, the cache will be invalid.
StepsID::ClearCache(); StepsID::ClearCache();
} }