forked from qt-creator/qt-creator
SaveFile: Fix error handling when moving file with new contents fails
The original content is moved to a backup, then the new file is moved
into its place. If that second step fails, we have to at least try
to move the backup back into the original place, and definitely
not remove the backup.
This behavior changed in 0dafe5cb8c
Task-number: QTCREATORBUG-21724
Change-Id: I996098576c0ceed59dd7359ac4f1b9d33f87d596
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -186,7 +186,8 @@ bool SaveFile::commit()
|
||||
const QString &renameError = m_tempFile->errorString();
|
||||
m_tempFile->remove();
|
||||
setErrorString(renameError);
|
||||
result = false;
|
||||
QFile::rename(backupName, finalFileName); // rollback to backup if possible ...
|
||||
return false; // ... or keep the backup copy at least
|
||||
}
|
||||
|
||||
QFile::remove(backupName);
|
||||
|
Reference in New Issue
Block a user