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:
parent
972f7471de
commit
967e1fcf02
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user