mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-09 17:07:43 +02:00
XMLFileWriter cleans up correctly in case of failure
This commit is contained in:
parent
c874519522
commit
fd2a242012
@ -302,10 +302,10 @@ XMLFileWriter::~XMLFileWriter()
|
|||||||
{
|
{
|
||||||
// Don't let a destructor throw!
|
// Don't let a destructor throw!
|
||||||
GuardedCall< void >( [&] {
|
GuardedCall< void >( [&] {
|
||||||
if (IsOpened()) {
|
if (!mCommitted) {
|
||||||
// Was not committed
|
|
||||||
auto fileName = GetName();
|
auto fileName = GetName();
|
||||||
CloseWithoutEndingTags();
|
if ( IsOpened() )
|
||||||
|
CloseWithoutEndingTags();
|
||||||
::wxRemoveFile( fileName );
|
::wxRemoveFile( fileName );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@ -340,6 +340,8 @@ void XMLFileWriter::Commit()
|
|||||||
throw FileException{
|
throw FileException{
|
||||||
FileException::Cause::Rename, tempPath, mCaption, mOutputPath
|
FileException::Cause::Rename, tempPath, mCaption, mOutputPath
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mCommitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLFileWriter::CloseWithoutEndingTags()
|
void XMLFileWriter::CloseWithoutEndingTags()
|
||||||
|
@ -111,6 +111,8 @@ class AUDACITY_DLL_API XMLFileWriter final : private wxFFile, public XMLWriter {
|
|||||||
const bool mKeepBackup;
|
const bool mKeepBackup;
|
||||||
|
|
||||||
wxFFile mBackupFile;
|
wxFFile mBackupFile;
|
||||||
|
|
||||||
|
bool mCommitted{ false };
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user