From 061e3fb07a91fe3b01d76cb768bd598c243be8d5 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Tue, 22 Aug 2006 13:45:36 +0000 Subject: [PATCH] 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. --- stepmania/src/Song.cpp | 7 +++++-- stepmania/src/Steps.cpp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 58da33ed0b..c8638cdf35 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -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() diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index eee01a7340..fa9a5ce262 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -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 ¬es_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() */