@@ -275,7 +275,7 @@ void QuitAudacity(bool bForce)
275275 // BG: Are there any projects open?
276276 // - if (!gAudacityProjects.IsEmpty())
277277/* start+*/
278- if (gAudacityProjects .IsEmpty ())
278+ if (gAudacityProjects .empty ())
279279 {
280280#ifdef __WXMAC__
281281 AudacityProject::DeleteClipboard ();
@@ -285,8 +285,10 @@ void QuitAudacity(bool bForce)
285285/* end+*/
286286 {
287287 SaveWindowSize ();
288- while (gAudacityProjects .Count ())
288+ while (gAudacityProjects .size ())
289289 {
290+ // Closing the project has global side-effect
291+ // of deletion from gAudacityProjects
290292 if (bForce)
291293 {
292294 gAudacityProjects [0 ]->Close (true );
@@ -339,12 +341,12 @@ void SaveWindowSize()
339341 bool validWindowForSaveWindowSize = FALSE ;
340342 AudacityProject * validProject = NULL ;
341343 bool foundIconizedProject = FALSE ;
342- size_t numProjects = gAudacityProjects .Count ();
344+ size_t numProjects = gAudacityProjects .size ();
343345 for (size_t i = 0 ; i < numProjects; i++)
344346 {
345347 if (!gAudacityProjects [i]->IsIconized ()) {
346348 validWindowForSaveWindowSize = TRUE ;
347- validProject = gAudacityProjects [i];
349+ validProject = gAudacityProjects [i]. get () ;
348350 i = numProjects;
349351 }
350352 else
@@ -370,7 +372,7 @@ void SaveWindowSize()
370372 else
371373 {
372374 if (foundIconizedProject) {
373- validProject = gAudacityProjects [0 ];
375+ validProject = gAudacityProjects [0 ]. get () ;
374376 bool wndMaximized = validProject->IsMaximized ();
375377 wxRect normalRect = validProject->GetNormalizedWindowState ();
376378 // store only the normal rectangle because the itemized rectangle
@@ -502,7 +504,7 @@ static gboolean save_yourself_cb(GnomeClient *client,
502504 return TRUE ;
503505 }
504506
505- if (gAudacityProjects .IsEmpty ()) {
507+ if (gAudacityProjects .empty ()) {
506508 return TRUE ;
507509 }
508510
@@ -723,7 +725,7 @@ void AudacityApp::MacNewFile()
723725 // This method should only be used on the Mac platform
724726 // when no project windows are open.
725727
726- if (gAudacityProjects .GetCount () == 0 ) {
728+ if (gAudacityProjects .size () == 0 ) {
727729 CreateNewAudacityProject ();
728730 }
729731}
@@ -886,19 +888,19 @@ void AudacityApp::OnTimer(wxTimerEvent& WXUNUSED(event))
886888 if (ShouldShowMissingAliasedFileWarning ()) {
887889 // find which project owns the blockfile
888890 // note: there may be more than 1, but just go with the first one.
889- size_t numProjects = gAudacityProjects .Count ();
891+ size_t numProjects = gAudacityProjects .size ();
890892 wxString missingFileName;
891893 AudacityProject *offendingProject = NULL ;
892894
893895 m_LastMissingBlockFileLock.Lock ();
894896 if (numProjects == 1 ) {
895897 // if there is only one project open, no need to search
896- offendingProject = gAudacityProjects [0 ];
898+ offendingProject = gAudacityProjects [0 ]. get () ;
897899 } else if (numProjects > 1 ) {
898900 for (size_t i = 0 ; i < numProjects; i++) {
899901 // search each project for the blockfile
900902 if (gAudacityProjects [i]->GetDirManager ()->ContainsBlockFile (m_LastMissingBlockFile)) {
901- offendingProject = gAudacityProjects [i];
903+ offendingProject = gAudacityProjects [i]. get () ;
902904 break ;
903905 }
904906 }
@@ -1973,8 +1975,10 @@ void AudacityApp::OnEndSession(wxCloseEvent & event)
19731975
19741976 // Try to close each open window. If the user hits Cancel
19751977 // in a Save Changes dialog, don't continue.
1976- if (!gAudacityProjects .IsEmpty ()) {
1977- while (gAudacityProjects .Count ()) {
1978+ if (!gAudacityProjects .empty ()) {
1979+ while (gAudacityProjects .size ()) {
1980+ // Closing the project has side-effect of
1981+ // deletion from gAudacityProjects
19781982 if (force) {
19791983 gAudacityProjects [0 ]->Close (true );
19801984 }
@@ -2077,7 +2081,7 @@ void AudacityApp::OnMenuNew(wxCommandEvent & event)
20772081 // this happens, and enable the same code to be present on
20782082 // all platforms.
20792083
2080- if (gAudacityProjects .GetCount () == 0 )
2084+ if (gAudacityProjects .size () == 0 )
20812085 CreateNewAudacityProject ();
20822086 else
20832087 event.Skip ();
@@ -2093,7 +2097,7 @@ void AudacityApp::OnMenuOpen(wxCommandEvent & event)
20932097 // all platforms.
20942098
20952099
2096- if (gAudacityProjects .GetCount () == 0 )
2100+ if (gAudacityProjects .size () == 0 )
20972101 AudacityProject::OpenFiles (NULL );
20982102 else
20992103 event.Skip ();
@@ -2109,7 +2113,7 @@ void AudacityApp::OnMenuPreferences(wxCommandEvent & event)
21092113 // this happens, and enable the same code to be present on
21102114 // all platforms.
21112115
2112- if (gAudacityProjects .GetCount () == 0 ) {
2116+ if (gAudacityProjects .size () == 0 ) {
21132117 GlobalPrefsDialog dialog (NULL /* parent */ );
21142118 dialog.ShowModal ();
21152119 }
@@ -2127,12 +2131,12 @@ void AudacityApp::OnMenuExit(wxCommandEvent & event)
21272131 // all platforms.
21282132
21292133 // LL: Removed "if" to allow closing based on final project count.
2130- // if(gAudacityProjects.GetCount () == 0)
2134+ // if(gAudacityProjects.size () == 0)
21312135 QuitAudacity ();
21322136
21332137 // LL: Veto quit if projects are still open. This can happen
21342138 // if the user selected Cancel in a Save dialog.
2135- event.Skip (gAudacityProjects .GetCount () == 0 );
2139+ event.Skip (gAudacityProjects .size () == 0 );
21362140
21372141}
21382142
0 commit comments