1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-16 09:31:14 +01:00

Guarded calls in batch processing

This commit is contained in:
Paul Licameli
2016-12-03 14:33:37 -05:00
parent eeb301e50d
commit 87e75176c5

View File

@@ -33,6 +33,7 @@
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/settings.h> #include <wx/settings.h>
#include "AudacityException.h"
#include "ShuttleGui.h" #include "ShuttleGui.h"
#include "Prefs.h" #include "Prefs.h"
#include "Project.h" #include "Project.h"
@@ -192,7 +193,8 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
bool success; bool success;
{ {
wxWindowDisabler wd(pD); wxWindowDisabler wd(pD);
success = mBatchCommands.ApplyChain(); success = GuardedCall< bool >(
[this]{ return mBatchCommands.ApplyChain(); } );
} }
if (!success) { if (!success) {
@@ -356,15 +358,21 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
mList->SetItemImage(i, 1, 1); mList->SetItemImage(i, 1, 1);
mList->EnsureVisible(i); mList->EnsureVisible(i);
project->Import(files[i]); auto success = GuardedCall< bool >( [&] {
project->OnSelectAll(); project->Import(files[i]);
if (!mBatchCommands.ApplyChain()) { project->OnSelectAll();
break; if (!mBatchCommands.ApplyChain())
} return false;
if (!pD->IsShown() || mAbort) { if (!pD->IsShown() || mAbort)
return false;
return true;
} );
if (!success)
break; break;
}
UndoManager *um = project->GetUndoManager(); UndoManager *um = project->GetUndoManager();
um->ClearStates(); um->ClearStates();
project->OnSelectAll(); project->OnSelectAll();