mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 00:50:52 +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)
|
if (pTrack->GetKind() == Track::Wave)
|
||||||
{
|
{
|
||||||
|
auto wasSelected = pTrack->GetSelected();
|
||||||
pTrack->SetSelected(true);
|
pTrack->SetSelected(true);
|
||||||
if (pTrack->GetLinked())
|
if (pTrack->GetLinked())
|
||||||
{
|
{
|
||||||
@ -4031,6 +4032,14 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
|
|||||||
else
|
else
|
||||||
pRightTrack = NULL;
|
pRightTrack = NULL;
|
||||||
|
|
||||||
|
auto cleanup = finally( [&] {
|
||||||
|
if (wasSelected) {
|
||||||
|
pTrack->SetSelected(false);
|
||||||
|
if (pRightTrack)
|
||||||
|
pRightTrack->SetSelected(false);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
uniqueTrackFileName = wxFileName(strDataDirPathName, pTrack->GetName(), wxT("ogg"));
|
uniqueTrackFileName = wxFileName(strDataDirPathName, pTrack->GetName(), wxT("ogg"));
|
||||||
FileNames::MakeNameUnique(mStrOtherNamesArray, uniqueTrackFileName);
|
FileNames::MakeNameUnique(mStrOtherNamesArray, uniqueTrackFileName);
|
||||||
bSuccess =
|
bSuccess =
|
||||||
@ -4038,9 +4047,8 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
|
|||||||
wxT("OGG"), uniqueTrackFileName.GetFullPath(), true,
|
wxT("OGG"), uniqueTrackFileName.GetFullPath(), true,
|
||||||
pTrack->GetStartTime(), pTrack->GetEndTime());
|
pTrack->GetStartTime(), pTrack->GetEndTime());
|
||||||
|
|
||||||
pTrack->SetSelected(false);
|
if (!bSuccess)
|
||||||
if (pRightTrack)
|
break;
|
||||||
pRightTrack->SetSelected(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,21 +922,26 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Select the track */
|
/* Select the track */
|
||||||
|
auto wasSelected = tr->GetSelected();
|
||||||
tr->SetSelected(true);
|
tr->SetSelected(true);
|
||||||
if (tr2) {
|
if (tr2) {
|
||||||
// Select it also
|
// Select it also
|
||||||
tr2->SetSelected(true);
|
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.
|
// Export the data. "channels" are per track.
|
||||||
ok = DoExport(activeSetting.channels, activeSetting.destfile, true, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
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
|
// Stop if an error occurred
|
||||||
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user