mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
refs #545 CAtomicFile::abandon() closes without renaming, and dtor abandons if it is called due to an exception being thrown.
This commit is contained in:
@@ -50,6 +50,11 @@ namespace BlackMisc
|
||||
return error() == NoError;
|
||||
}
|
||||
|
||||
void CAtomicFile::abandon()
|
||||
{
|
||||
QFile::close();
|
||||
}
|
||||
|
||||
CAtomicFile::FileError CAtomicFile::error() const
|
||||
{
|
||||
if (m_renameError) { return RenameError; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user