1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

XMLFileWriter cleans up correctly in case of failure

This commit is contained in:
Paul Licameli 2017-10-23 17:08:24 -04:00
parent c874519522
commit fd2a242012
2 changed files with 7 additions and 3 deletions

View File

@ -302,10 +302,10 @@ XMLFileWriter::~XMLFileWriter()
{
// Don't let a destructor throw!
GuardedCall< void >( [&] {
if (IsOpened()) {
// Was not committed
if (!mCommitted) {
auto fileName = GetName();
CloseWithoutEndingTags();
if ( IsOpened() )
CloseWithoutEndingTags();
::wxRemoveFile( fileName );
}
} );
@ -340,6 +340,8 @@ void XMLFileWriter::Commit()
throw FileException{
FileException::Cause::Rename, tempPath, mCaption, mOutputPath
};
mCommitted = true;
}
void XMLFileWriter::CloseWithoutEndingTags()

View File

@ -111,6 +111,8 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter {
const bool mKeepBackup;
wxFFile mBackupFile;
bool mCommitted{ false };
};
///