1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-21 23:00:06 +02:00

shared_ptr manages AudacityProject objects, so weak_ptr may be used

This commit is contained in:
Paul Licameli 2016-08-15 11:42:18 -04:00
parent 3c4ac1861c
commit 5752dbab02
2 changed files with 12 additions and 10 deletions

View File

@ -526,14 +526,16 @@ AudacityProject *CreateNewAudacityProject()
bool bIconized;
GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized);
//Create and show a NEW project
gAudacityProjects.push_back(
make_movable_with_deleter<AudacityProject, Destroyer< AudacityProject > >
({},
nullptr, -1,
wxDefaultPosition,
wxSize(wndRect.width, wndRect.height))
);
// Create and show a NEW project
// Use a non-default deleter in the smart pointer!
gAudacityProjects.push_back( AProjectHolder {
safenew AudacityProject(
nullptr, -1,
wxDefaultPosition,
wxSize(wndRect.width, wndRect.height)
),
Destroyer< AudacityProject > {}
} );
const auto p = gAudacityProjects.back().get();
// wxGTK3 seems to need to require creating the window using default position

View File

@ -110,8 +110,8 @@ void GetDefaultWindowRect(wxRect *defRect);
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
bool IsWindowAccessible(wxRect *requestedRect);
using AProjectHolder =
movable_ptr_with_deleter< AudacityProject, Destroyer< AudacityProject > >;
// Use shared_ptr to projects, because elsewhere we need weak_ptr
using AProjectHolder = std::shared_ptr< AudacityProject >;
using AProjectArray = std::vector< AProjectHolder >;
extern AProjectArray gAudacityProjects;