From 87e75176c53219416714a78bdf358469bfd97df6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 3 Dec 2016 14:33:37 -0500 Subject: [PATCH] Guarded calls in batch processing --- src/BatchProcessDialog.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 9ce8e3421..c7297977d 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -33,6 +33,7 @@ #include #include +#include "AudacityException.h" #include "ShuttleGui.h" #include "Prefs.h" #include "Project.h" @@ -192,7 +193,8 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event)) bool success; { wxWindowDisabler wd(pD); - success = mBatchCommands.ApplyChain(); + success = GuardedCall< bool >( + [this]{ return mBatchCommands.ApplyChain(); } ); } if (!success) { @@ -356,15 +358,21 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event)) mList->SetItemImage(i, 1, 1); mList->EnsureVisible(i); - project->Import(files[i]); - project->OnSelectAll(); - if (!mBatchCommands.ApplyChain()) { - break; - } + auto success = GuardedCall< bool >( [&] { + project->Import(files[i]); + project->OnSelectAll(); + if (!mBatchCommands.ApplyChain()) + return false; - if (!pD->IsShown() || mAbort) { + if (!pD->IsShown() || mAbort) + return false; + + return true; + } ); + + if (!success) break; - } + UndoManager *um = project->GetUndoManager(); um->ClearStates(); project->OnSelectAll();