Invert logic of CAtomicFile destructor:

abandon changes if destruction is due to an exception,
instead of applying changes if destruction is NOT due to an exception.
Because otherwise QFile destructor will apply changes regardless,
by calling the close method via virtual dispatch.
This commit is contained in:
Mathew Sutcliffe
2016-08-10 00:03:56 +01:00
parent 3c82bb3a9c
commit f8fc82019d

View File

@@ -35,7 +35,7 @@ namespace BlackMisc
CAtomicFile(const QString &filename) : QFile(filename) {}
//! \copydoc QFile::~QFile
~CAtomicFile() { if (! std::uncaught_exception()) { close(); } }
~CAtomicFile() { if (std::uncaught_exception()) { QFile::close(); } }
//! \copydoc QFile::open
//! Just before opening the file, the filename is changed so we actually write to a temporary file.