1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-17 14:11:13 +01:00

Limit access to global array of open projects & simplify iterations

This commit is contained in:
Paul Licameli
2019-05-29 14:19:01 -04:00
parent 0ae542cf08
commit b25d3ad344
15 changed files with 203 additions and 185 deletions

View File

@@ -179,9 +179,7 @@ void DoReloadPreferences( AudacityProject &project )
// LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
// rebuilding the menus while the PrefsDialog is still in the modal
// state.
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
AudacityProject *p = gAudacityProjects[i].get();
for (auto p : AllProjects{}) {
MenuManager::Get(*p).RebuildMenuBar(*p);
// TODO: The comment below suggests this workaround is obsolete.
#if defined(__WXGTK__)
@@ -1031,9 +1029,7 @@ void OnPreferences(const CommandContext &context)
// LL: Moved from PrefsDialog since wxWidgets on OSX can't deal with
// rebuilding the menus while the PrefsDialog is still in the modal
// state.
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
AudacityProject *p = gAudacityProjects[i].get();
for (auto p : AllProjects{}) {
MenuManager::Get(*p).RebuildMenuBar(*p);
// TODO: The comment below suggests this workaround is obsolete.
#if defined(__WXGTK__)

View File

@@ -94,16 +94,14 @@ void DoPlayStop(const CommandContext &context)
// old and start the NEW.
//find out which project we need;
AudacityProject* otherProject = NULL;
for(unsigned i=0; i<gAudacityProjects.size(); i++) {
if(gAudioIO->IsStreamActive(gAudacityProjects[i]->GetAudioIOToken())) {
otherProject=gAudacityProjects[i].get();
break;
}
}
auto start = AllProjects{}.begin(), finish = AllProjects{}.end(),
iter = std::find_if( start, finish,
[]( const AllProjects::value_type &ptr ){
return gAudioIO->IsStreamActive(ptr->GetAudioIOToken()); } );
//stop playing the other project
if(otherProject) {
if(iter != finish) {
auto otherProject = *iter;
auto &otherToolbar = ControlToolBar::Get( *otherProject );
otherToolbar.SetPlay(false); //Pops
otherToolbar.SetStop(true); //Pushes stop down
@@ -407,7 +405,7 @@ void OnTimerRecord(const CommandContext &context)
// MY: Due to improvements in how Timer Recording saves and/or exports
// it is now safer to disable Timer Recording when there is more than
// one open project.
if (AudacityProject::GetOpenProjectCount() > 1) {
if (AllProjects{}.size() > 1) {
AudacityMessageBox(_("Timer Recording cannot be used with more than one open project.\n\nPlease close any additional projects and try again."),
_("Timer Recording"),
wxICON_INFORMATION | wxOK);

View File

@@ -89,13 +89,13 @@ void OnMacBringAllToFront(const CommandContext &)
{
// Reall this de-miniaturizes all, which is not exactly the standard
// behavior.
for (const auto project : gAudacityProjects)
for (const auto project : AllProjects{})
GetProjectFrame( *project ).Raise();
}
void OnMacMinimizeAll(const CommandContext &)
{
for (const auto project : gAudacityProjects) {
for (const auto project : AllProjects{}) {
DoMacMinimize(project.get());
}
}