aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-12-17 09:18:57 +0100
committerEike Ziller <eike.ziller@qt.io>2018-12-17 13:05:31 +0000
commit40f2f9971409acf3e2e531411826a01ed5223561 (patch)
tree99fcb1d041fa07bafc17ce339e5471572f99eca9
parent18bee3a08f9339c0fb33a732a1fe45b2b8a9622c (diff)
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 0dafe5cb8c8135d365c8cb0d365eae5ce66d268e Task-number: QTCREATORBUG-21724 Change-Id: I996098576c0ceed59dd7359ac4f1b9d33f87d596 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/libs/utils/savefile.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libs/utils/savefile.cpp b/src/libs/utils/savefile.cpp
index 5864ece3ef..cac25546db 100644
--- a/src/libs/utils/savefile.cpp
+++ b/src/libs/utils/savefile.cpp
@@ -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);