1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-07 17:43:53 +01:00

Define InvisibleTemporaryProject

This commit is contained in:
Paul Licameli
2020-11-18 23:42:42 -05:00
parent 93b098b8d2
commit a9cbd953f0
2 changed files with 36 additions and 0 deletions

View File

@@ -2401,3 +2401,25 @@ int ProjectFileIO::get_varint(const unsigned char *ptr, int64_t *out)
return 9;
}
InvisibleTemporaryProject::InvisibleTemporaryProject()
: mpProject{ std::make_shared< AudacityProject >() }
{
}
InvisibleTemporaryProject::~InvisibleTemporaryProject()
{
auto &projectFileIO = ProjectFileIO::Get( Project() );
projectFileIO.SetBypass();
auto &tracks = TrackList::Get( Project() );
tracks.Clear();
// Consume some delayed track list related events before destroying the
// temporary project
try { wxTheApp->Yield(); } catch(...) {}
// Destroy the project and yield again to let delayed window deletions happen
projectFileIO.CloseProject();
mpProject.reset();
try { wxTheApp->Yield(); } catch(...) {}
}

View File

@@ -262,4 +262,18 @@ public:
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_PROJECT_TITLE_CHANGE, wxCommandEvent);
//! Makes a temporary project that doesn't display on the screen
class InvisibleTemporaryProject
{
public:
InvisibleTemporaryProject();
~InvisibleTemporaryProject();
AudacityProject &Project()
{
return *mpProject;
}
private:
std::shared_ptr<AudacityProject> mpProject;
};
#endif