mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 17:10:55 +02:00
XMLFileWriter cleans up correctly in case of failure
This commit is contained in:
parent
874d8da025
commit
a6c69dec74
@ -302,9 +302,9 @@ XMLFileWriter::~XMLFileWriter()
|
||||
{
|
||||
// Don't let a destructor throw!
|
||||
GuardedCall< void >( [&] {
|
||||
if (IsOpened()) {
|
||||
// Was not committed
|
||||
if (!mCommitted) {
|
||||
auto fileName = GetName();
|
||||
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()
|
||||
|
@ -111,6 +111,8 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter {
|
||||
const bool mKeepBackup;
|
||||
|
||||
wxFFile mBackupFile;
|
||||
|
||||
bool mCommitted{ false };
|
||||
};
|
||||
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user