1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 08:27:13 +01:00

New attached structure ProjectManager handles project lifetime...

... that is, a factory function, open, close, import, undo/redo/rollback.

Also the callbacks from AudioIO, which need to invoke undo history push when
recording stops.

It is meant as a high-level class using several of the other things attached
to the project, while AudacityProject will be a low level class acting mostly
as just the container of the attached structures.
This commit is contained in:
Paul Licameli
2019-04-29 02:22:08 -04:00
parent c629d44c41
commit 4274d44ab7
50 changed files with 706 additions and 551 deletions

View File

@@ -810,9 +810,8 @@ void AudacityApp::MacNewFile()
// This method should only be used on the Mac platform
// when no project windows are open.
if (AllProjects{}.empty()) {
CreateNewAudacityProject();
}
if (AllProjects{}.empty())
(void) ProjectManager::New();
}
#endif //__WXMAC__
@@ -880,7 +879,7 @@ bool AudacityApp::MRUOpen(const FilePath &fullPathStr) {
// Test here even though AudacityProject::OpenFile() also now checks, because
// that method does not return the bad result.
// That itself may be a FIXME.
if (AudacityProject::IsAlreadyOpen(fullPathStr))
if (ProjectManager::IsAlreadyOpen(fullPathStr))
return false;
// DMM: If the project is dirty, that means it's been touched at
@@ -893,12 +892,15 @@ bool AudacityApp::MRUOpen(const FilePath &fullPathStr) {
// there are no tracks, but there's an Undo history, etc, then
// bad things can happen, including data files moving to the NEW
// project directory, etc.
if (proj && (proj->GetDirty() || !TrackList::Get( *proj ).empty()))
if (proj && (
ProjectManager::Get( *proj ).GetDirty() ||
!TrackList::Get( *proj ).empty()
) )
proj = nullptr;
// This project is clean; it's never been touched. Therefore
// all relevant member variables are in their initial state,
// and it's okay to open a NEW project inside this window.
AudacityProject::OpenProject( proj, fullPathStr );
( void ) ProjectManager::OpenProject( proj, fullPathStr );
}
else {
// File doesn't exist - remove file from history
@@ -936,7 +938,7 @@ void AudacityApp::OnMRUFile(wxCommandEvent& event) {
// PRL: Don't call SafeMRUOpen
// -- if open fails for some exceptional reason of resource exhaustion that
// the user can correct, leave the file in history.
if (!AudacityProject::IsAlreadyOpen(fullPathStr) && !MRUOpen(fullPathStr))
if (!ProjectManager::IsAlreadyOpen(fullPathStr) && !MRUOpen(fullPathStr))
history.RemoveFileFromHistory(n);
}
@@ -1073,7 +1075,7 @@ bool AudacityApp::OnExceptionInMainLoop()
// Restore the state of the project to what it was before the
// failed operation
if (pProject) {
pProject->RollbackState();
ProjectManager::Get( *pProject ).RollbackState();
// Forget pending changes in the TrackList
TrackList::Get( *pProject ).ClearPendingTracks();
@@ -1511,7 +1513,7 @@ bool AudacityApp::OnInit()
// Root cause is problem with wxSplashScreen and other dialogs co-existing, that
// seemed to arrive with wx3.
{
project = CreateNewAudacityProject();
project = ProjectManager::New();
mCmdHandler->SetProject(project);
wxWindow * pWnd = MakeHijackPanel();
if (pWnd)
@@ -2081,7 +2083,7 @@ void AudacityApp::OnMenuNew(wxCommandEvent & event)
// all platforms.
if(AllProjects{}.empty())
CreateNewAudacityProject();
(void) ProjectManager::New();
else
event.Skip();
}
@@ -2097,7 +2099,7 @@ void AudacityApp::OnMenuOpen(wxCommandEvent & event)
if(AllProjects{}.empty())
AudacityProject::OpenFiles(NULL);
ProjectManager::OpenFiles(NULL);
else
event.Skip();