From 0bd9bb3b909bbb41cf0340273832b686e595e8bb Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 2 May 2019 06:24:29 -0400 Subject: [PATCH] Some steps of ResetProjectToEmpty into a new function --- src/Project.cpp | 13 ++++++++++--- src/Project.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index 3c0b69086..8c56a7a2a 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -5335,6 +5335,7 @@ bool AudacityProject::IsProjectSaved() { // This is done to empty out the tracks, but without creating a new project. void AudacityProject::ResetProjectToEmpty() { auto &project = *this; + auto &projectFileIO = project; SelectActions::DoSelectAll( project ); TrackActions::DoRemoveTracks( project ); @@ -5342,20 +5343,26 @@ void AudacityProject::ResetProjectToEmpty() { mDirManager = DirManager::Create(); mTrackFactory.reset(safenew TrackFactory{ mDirManager, &mViewInfo }); + projectFileIO.ResetProjectFileIO(); + + mDirty = false; + GetUndoManager()->ClearStates(); +} + +void AudacityProject::ResetProjectFileIO() +{ // mLastSavedTrack code copied from OnCloseWindow. // Lock all blocks in all tracks of the last saved version, so that // the blockfiles aren't deleted on disk when we DELETE the blockfiles // in memory. After it's locked, DELETE the data structure so that // there's no memory leak. - project.CloseLock(); + CloseLock(); //mLastSavedTracks = TrackList::Create(); mFileName = ""; mIsRecovered = false; mbLoadedFromAup = false; SetProjectTitle(); - mDirty = false; - GetUndoManager()->ClearStates(); } bool AudacityProject::SaveFromTimerRecording(wxFileName fnFile) { diff --git a/src/Project.h b/src/Project.h index 0504d9e49..a2f5ea230 100644 --- a/src/Project.h +++ b/src/Project.h @@ -352,6 +352,7 @@ public: static int GetOpenProjectCount(); bool IsProjectSaved(); void ResetProjectToEmpty(); + void ResetProjectFileIO(); // Routine to estimate how many minutes of recording time are left on disk int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);