From 4d4cd91d910a104900dd54c8f9f8ee22f1a852e6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 19 Dec 2016 14:13:46 -0500 Subject: [PATCH] Hoist, and delay, the saving of import tag while opening the file... ... so that AudacityProject::AudacityProject no longer has a path in the static call graph that reaches block file write operations that might throw. So it is easier to prove that other functions, calling that, don't throw. Also delay the possibly thowing save of the import until after certain other steps in the file opening procedure. --- src/Project.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index 84ff368ea..68064d633 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -3124,6 +3124,8 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory) wxGetApp().AddFileToHistory(fileName); } + bool saved = false; + if (mIsRecovered) { // This project has been recovered, so write a NEW auto-save file @@ -3182,9 +3184,20 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory) // this->PushState(_("Project checker repaired file"), _("Project Repair")); if (status & FSCKstatus_SAVE_AUP) - this->Save(); + this->Save(), saved = true; } } + + if (mImportXMLTagHandler) { + if (!saved) + // We processed an tag, so save it as a normal project, + // with no tags. + this->Save(); + + // Shouldn't need it any more. + mImportXMLTagHandler.reset(); + } + } else { // Vaughan, 2011-10-30: // See first topic at http://bugzilla.audacityteam.org/show_bug.cgi?id=451#c16. @@ -4298,14 +4311,6 @@ For an audio file that will open in other apps, use 'Export'.\n"), void AudacityProject::InitialState() { - if (mImportXMLTagHandler) { - // We processed an tag, so save it as a normal project, with no tags. - this->Save(); - - // Shouldn't need it any more. - mImportXMLTagHandler.reset(); - } - GetUndoManager()->ClearStates(); GetUndoManager()->PushState(GetTracks(), mViewInfo.selectedRegion, mTags,