1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 14:18:53 +02:00

More exception safety for selection states of tracks

This commit is contained in:
Paul Licameli 2017-04-22 23:43:10 -04:00
parent 972f7471de
commit 967e1fcf02
2 changed files with 22 additions and 9 deletions

View File

@ -4022,6 +4022,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
{
if (pTrack->GetKind() == Track::Wave)
{
auto wasSelected = pTrack->GetSelected();
pTrack->SetSelected(true);
if (pTrack->GetLinked())
{
@ -4031,6 +4032,14 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
else
pRightTrack = NULL;
auto cleanup = finally( [&] {
if (wasSelected) {
pTrack->SetSelected(false);
if (pRightTrack)
pRightTrack->SetSelected(false);
}
} );
uniqueTrackFileName = wxFileName(strDataDirPathName, pTrack->GetName(), wxT("ogg"));
FileNames::MakeNameUnique(mStrOtherNamesArray, uniqueTrackFileName);
bSuccess =
@ -4038,9 +4047,8 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
wxT("OGG"), uniqueTrackFileName.GetFullPath(), true,
pTrack->GetStartTime(), pTrack->GetEndTime());
pTrack->SetSelected(false);
if (pRightTrack)
pRightTrack->SetSelected(false);
if (!bSuccess)
break;
}
}

View File

@ -922,21 +922,26 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
}
/* Select the track */
auto wasSelected = tr->GetSelected();
tr->SetSelected(true);
if (tr2) {
// Select it also
tr2->SetSelected(true);
}
auto cleanup = finally( [&] {
if (!wasSelected) {
// Reset selection state
tr->SetSelected(false);
if (tr2) {
tr2->SetSelected(false);
}
}
} );
// Export the data. "channels" are per track.
ok = DoExport(activeSetting.channels, activeSetting.destfile, true, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
// Reset selection state
tr->SetSelected(false);
if (tr2) {
tr2->SetSelected(false);
}
// Stop if an error occurred
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
break;