diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 22ff3c67c..1ddb85e3f 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -975,7 +975,6 @@ ProjectFileManager::AddImportedTracks(const FilePath &fileName, auto &history = ProjectHistory::Get( project ); auto &projectFileIO = ProjectFileIO::Get( project ); auto &tracks = TrackList::Get( project ); - const auto& playableTracks = tracks.Any(); std::vector< std::shared_ptr< Track > > results; @@ -988,16 +987,11 @@ ProjectFileManager::AddImportedTracks(const FilePath &fileName, wxString trackNameBase = fn.GetName(); int i = -1; - // Next for- and if-statements fix the bug 2109. + // Fix the bug 2109. // In case the project had soloed tracks before importing, // all newly imported tracks are muted. - bool projectHasSolo{ false }; - for (const auto& track : playableTracks) - { - if (track->GetSolo()) - projectHasSolo = true; - } - + const bool projectHasSolo = + !(tracks.Any() + &PlayableTrack::GetSolo).empty(); if (projectHasSolo) { for (auto& track : newTracks) diff --git a/src/import/ImportMIDI.cpp b/src/import/ImportMIDI.cpp index f93f98038..b8422b4d4 100644 --- a/src/import/ImportMIDI.cpp +++ b/src/import/ImportMIDI.cpp @@ -44,6 +44,14 @@ bool DoImportMIDI( AudacityProject &project, const FilePath &fileName ) auto pTrack = tracks.Add( newTrack ); pTrack->SetSelected(true); + // Fix the bug 2109. + // In case the project had soloed tracks before importing, + // the newly imported track is muted. + const bool projectHasSolo = + !(tracks.Any() + &PlayableTrack::GetSolo).empty(); + if (projectHasSolo) + pTrack->SetMute(true); + ProjectHistory::Get( project ) .PushState( XO("Imported MIDI from '%s'").Format( fileName ),