diff --git a/src/blackmisc/atomicfile.cpp b/src/blackmisc/atomicfile.cpp index 7eabdeaca..55d7f2240 100644 --- a/src/blackmisc/atomicfile.cpp +++ b/src/blackmisc/atomicfile.cpp @@ -50,6 +50,11 @@ namespace BlackMisc return error() == NoError; } + void CAtomicFile::abandon() + { + QFile::close(); + } + CAtomicFile::FileError CAtomicFile::error() const { if (m_renameError) { return RenameError; } diff --git a/src/blackmisc/atomicfile.h b/src/blackmisc/atomicfile.h index 03ae71f8f..f99afc710 100644 --- a/src/blackmisc/atomicfile.h +++ b/src/blackmisc/atomicfile.h @@ -30,7 +30,7 @@ namespace BlackMisc CAtomicFile(const QString &filename) : QFile(filename) {} //! \copydoc QFile::~QFile - ~CAtomicFile() { close(); } + ~CAtomicFile() { if (! std::uncaught_exception()) { close(); } } //! \copydoc QFile::open //! Just before opening the file, the filename is changed so we actually write to a temporary file. @@ -43,6 +43,9 @@ namespace BlackMisc //! Calls close() and returns false if there was an error at any stage. bool checkedClose(); + //! Closes the file without renaming it. + void abandon(); + //! \copydoc QFileDevice::error FileError error() const;