mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-07 17:43:53 +01:00
Define InvisibleTemporaryProject
This commit is contained in:
@@ -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(...) {}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user