1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-21 05:35:45 +01:00

Exception safety in: subclasses of ExportPlugin; and more error checking

This commit is contained in:
Paul Licameli
2016-12-24 08:57:27 -05:00
parent 48459404a5
commit 0c8bedc59a
8 changed files with 156 additions and 95 deletions

View File

@@ -354,14 +354,19 @@ ProgressResult ExportCL::Export(AudacityProject *project,
// Kick off the command
ExportCLProcess process(&output);
rc = wxExecute(cmd, wxEXEC_ASYNC, &process);
{
#if defined(__WXMSW__)
if (!opath.IsEmpty()) {
wxSetEnv(wxT("PATH"),opath.c_str());
}
auto cleanup = finally( [&] {
if (!opath.IsEmpty()) {
wxSetEnv(wxT("PATH"),opath.c_str());
}
} );
#endif
rc = wxExecute(cmd, wxEXEC_ASYNC, &process);
}
if (!rc) {
wxMessageBox(wxString::Format(_("Cannot export audio to %s"),
fName.c_str()));
@@ -435,6 +440,11 @@ ProgressResult ExportCL::Export(AudacityProject *project,
auto updateResult = ProgressResult::Success;
{
auto closeIt = finally ( [&] {
// Should make the process die, before propagating any exception
process.CloseOutput();
} );
// Prepare the progress display
ProgressDialog progress(_("Export"),
selectionOnly ?
@@ -475,6 +485,7 @@ ProgressResult ExportCL::Export(AudacityProject *project,
while (bytes > 0) {
os->Write(mixed, bytes);
if (!os->IsOk()) {
updateResult = ProgressResult::Cancelled;
break;
}
bytes -= os->LastWrite();
@@ -487,9 +498,6 @@ ProgressResult ExportCL::Export(AudacityProject *project,
// Done with the progress display
}
// Should make the process die
process.CloseOutput();
// Wait for process to terminate
while (process.IsActive()) {
wxMilliSleep(10);