1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 00:29:41 +02:00

Bug451 re-fix: When file open fails, don't erase blockfiles

The original fix of years ago must have caused leaked memory, and was
undone by my other changes to track memory management.  This fix preserves
the intent, and avoids leaked memory.
This commit is contained in:
Paul Licameli 2016-12-19 13:24:26 -05:00
parent e8ac12160a
commit 79c07bd5c1

View File

@ -3158,6 +3158,18 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
// Vaughan, 2011-10-30:
// See first topic at http://bugzilla.audacityteam.org/show_bug.cgi?id=451#c16.
// Calling mTracks->Clear() with deleteTracks true results in data loss.
// PRL 2014-12-19:
// I made many changes for wave track memory management, but only now
// read the above comment. I may have invalidated the fix above (which
// may have spared the files at the expense of leaked memory). But
// here is a better way to accomplish the intent, doing like what happens
// when the project closes:
TrackListOfKindIterator iter(Track::Wave, mTracks.get() );
for ( Track *pTrack = iter.First(); pTrack; pTrack = iter.Next() ) {
static_cast< WaveTrack* >(pTrack)->CloseLock();
}
mTracks->Clear(); //mTracks->Clear(true);
mFileName = wxT("");