SetSavedToDisk in Save(), not in SM_SaveSuccessful. When we save the
whole file, all steps are saved to disk; we were only marking the
active steps. This sequence would cause steps to be wrongly deleted:
1: create easy and medium steps for one steps type; save
2: on another steps type, edit easy steps which were autogenned from the above
change the steps
3: f6 to change to medium steps steps which were autogenned from the above
4: menu -> save
This will save all data, but only medium will be marked saved to disk.
5: f5 to change back to easy steps
6: menu -> exit
This will delete the easy steps, because they were not marked saved to disk.
This commit is contained in:
@@ -195,7 +195,7 @@ static RString GetSMNotesTag( const Song &song, const Steps &in, bool bSavingCac
|
|||||||
return JoinLineList( lines );
|
return JoinLineList( lines );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotesWriterSM::Write( RString sPath, const Song &out, bool bSavingCache )
|
bool NotesWriterSM::Write( RString sPath, const Song &out, const vector<Steps*>& vpStepsToSave, bool bSavingCache )
|
||||||
{
|
{
|
||||||
/* Flush dir cache when writing steps, so the old size isn't cached. */
|
/* Flush dir cache when writing steps, so the old size isn't cached. */
|
||||||
FILEMAN->FlushDirCache( Dirname(sPath) );
|
FILEMAN->FlushDirCache( Dirname(sPath) );
|
||||||
@@ -229,19 +229,11 @@ bool NotesWriterSM::Write( RString sPath, const Song &out, bool bSavingCache )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save all Steps for this file
|
// Save specified Steps to this file
|
||||||
//
|
//
|
||||||
const vector<Steps*>& vpSteps = out.GetAllSteps();
|
FOREACH_CONST( Steps*, vpStepsToSave, s )
|
||||||
FOREACH_CONST( Steps*, vpSteps, s )
|
|
||||||
{
|
{
|
||||||
const Steps* pSteps = *s;
|
const Steps* pSteps = *s;
|
||||||
if( pSteps->IsAutogen() )
|
|
||||||
continue; /* don't write autogen notes */
|
|
||||||
|
|
||||||
/* Only save steps that weren't loaded from a profile. */
|
|
||||||
if( pSteps->WasLoadedFromProfile() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
RString sTag = GetSMNotesTag( out, *pSteps, bSavingCache );
|
RString sTag = GetSMNotesTag( out, *pSteps, bSavingCache );
|
||||||
f.PutLine( sTag );
|
f.PutLine( sTag );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Song;
|
|||||||
class Steps;
|
class Steps;
|
||||||
namespace NotesWriterSM
|
namespace NotesWriterSM
|
||||||
{
|
{
|
||||||
bool Write( RString sPath, const Song &out, bool bSavingCache );
|
bool Write( RString sPath, const Song &out, const vector<Steps*>& vpStepsToSave, bool bSavingCache );
|
||||||
void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut );
|
void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut );
|
||||||
RString GetEditFileName( const Song *pSong, const Steps *pSteps );
|
RString GetEditFileName( const Song *pSong, const Steps *pSteps );
|
||||||
bool WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut );
|
bool WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut );
|
||||||
|
|||||||
@@ -2551,7 +2551,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
else if( SM == SM_SaveSuccessful )
|
else if( SM == SM_SaveSuccessful )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Save successful." );
|
LOG->Trace( "Save successful." );
|
||||||
m_pSteps->SetSavedToDisk( true );
|
|
||||||
CopyToLastSave();
|
CopyToLastSave();
|
||||||
SetDirty( false );
|
SetDirty( false );
|
||||||
SONGMAN->Invalidate( GAMESTATE->m_pCurSong );
|
SONGMAN->Invalidate( GAMESTATE->m_pCurSong );
|
||||||
@@ -2806,6 +2805,8 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pSteps->SetSavedToDisk( true );
|
||||||
|
|
||||||
// HACK: clear undo, so "exit" below knows we don't need to save.
|
// HACK: clear undo, so "exit" below knows we don't need to save.
|
||||||
// This only works because important non-steps data can't be changed in
|
// This only works because important non-steps data can't be changed in
|
||||||
// home mode (BPMs, stops).
|
// home mode (BPMs, stops).
|
||||||
|
|||||||
+25
-1
@@ -819,7 +819,31 @@ bool Song::SaveToSMFile( RString sPath, bool bSavingCache )
|
|||||||
if( !bSavingCache && IsAFile(sPath) )
|
if( !bSavingCache && IsAFile(sPath) )
|
||||||
FileCopy( sPath, sPath + ".old" );
|
FileCopy( sPath, sPath + ".old" );
|
||||||
|
|
||||||
return NotesWriterSM::Write( sPath, *this, bSavingCache );
|
vector<Steps*> vpStepsToSave;
|
||||||
|
FOREACH_CONST( Steps*, m_vpSteps, s )
|
||||||
|
{
|
||||||
|
Steps *pSteps = *s;
|
||||||
|
if( pSteps->IsAutogen() )
|
||||||
|
continue; /* don't write autogen notes */
|
||||||
|
|
||||||
|
/* Only save steps that weren't loaded from a profile. */
|
||||||
|
if( pSteps->WasLoadedFromProfile() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vpStepsToSave.push_back( pSteps );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !NotesWriterSM::Write(sPath, *this, vpStepsToSave, bSavingCache) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !bSavingCache )
|
||||||
|
{
|
||||||
|
/* Mark these steps saved to disk. */
|
||||||
|
FOREACH( Steps*, vpStepsToSave, s )
|
||||||
|
(*s)->SetSavedToDisk( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::SaveToCacheFile()
|
bool Song::SaveToCacheFile()
|
||||||
|
|||||||
Reference in New Issue
Block a user