1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 15:53:52 +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

@@ -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;