From 745237c81234142c9e807287521b21f8299f09d5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 3 Feb 2007 02:14:25 +0000 Subject: [PATCH] fix: "// FIXME: This logic fails if the user starts a new steps, changes to // a different stepchart, and then exits without saving" --- stepmania/src/ScreenEdit.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index a3c38961e7..a7adcce36b 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2573,18 +2573,25 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) // IMPORTANT: CopyFromLastSave before deleting the Steps below CopyFromLastSave(); - // If these steps have never been saved, then we should delete them. - // If the user created them in the edit menu and never bothered - // to save them, then they aren't wanted. - // FIXME: This logic fails if the user starts a new steps, changes to - // a different stepchart, and then exits without saving - Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1]; - if( !pSteps->GetSavedToDisk() ) + /* The user has been given a choice to save. Delete all unsaved + * steps before exiting the editor. */ + Song *pSong = GAMESTATE->m_pCurSong; + const vector &apSteps = pSong->GetAllSteps(); + vector apToDelete; + FOREACH_CONST( Steps *, apSteps, s ) { - Song* pSong = GAMESTATE->m_pCurSong; + if( (*s)->IsAutogen() || (*s)->GetSavedToDisk() ) + continue; + apToDelete.push_back( *s ); + } + FOREACH_CONST( Steps *, apToDelete, s ) + { + Steps *pSteps = *s; pSong->DeleteSteps( pSteps ); - m_pSteps = NULL; - GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL ); + if( m_pSteps == pSteps ) + m_pSteps = NULL; + if( GAMESTATE->m_pCurSteps[PLAYER_1].Get() == pSteps ) + GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL ); } m_Out.StartTransitioning( SM_GoToNextScreen );