When Steps have changed in memory but not on disk, calling Compress() could lose all changes in memory. Clear the file name to ensure this doesn't happen and reset it when the Song has been written to cache once more.

This commit is contained in:
Steve Checkoway
2006-08-22 13:45:36 +00:00
parent ed2331b839
commit 061e3fb07a
2 changed files with 7 additions and 4 deletions
+5 -2
View File
@@ -757,13 +757,16 @@ void Song::SaveToSMFile( RString sPath, bool bSavingCache )
FileCopy( sPath, sPath + ".old" );
NotesWriterSM wr;
wr.Write(sPath, *this, bSavingCache);
wr.Write( sPath, *this, bSavingCache );
}
void Song::SaveToCacheFile()
{
SONGINDEX->AddCacheIndex(m_sSongDir, GetHashForDirectory(m_sSongDir));
SaveToSMFile( GetCacheFilePath(), true );
const RString sPath = GetCacheFilePath();
SaveToSMFile( sPath, true );
FOREACH( Steps*, m_vpSteps, pSteps )
(*pSteps)->SetFilename( sPath );
}
void Song::SaveToDWIFile()
+2 -2
View File
@@ -63,12 +63,11 @@ void Steps::SetNoteData( const NoteData& noteDataNew )
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
m_uHash = GetHashForString( m_sNoteDataCompressed );
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
}
void Steps::GetNoteData( NoteData& noteDataOut ) const
{
ASSERT(this);
Decompress();
if( m_bNoteDataIsFilled )
@@ -89,6 +88,7 @@ void Steps::SetSMNoteData( const RString &notes_comp_ )
m_sNoteDataCompressed = notes_comp_;
m_uHash = GetHashForString( m_sNoteDataCompressed );
m_sFilename = EMPTY_STRING; // We can no longer read from the file because it has changed in memory.
}
/* XXX: this function should pull data from m_sFilename, like Decompress() */