From 7e11c7bd50b8b11a60bf7b813d795283162f54b6 Mon Sep 17 00:00:00 2001 From: Heewa Barfchin Date: Wed, 12 May 2021 22:16:45 -0400 Subject: [PATCH] App: Abort save when unable to finish In these two cases, the project's file will not contain the latest changes, so returning as if the save is complete is incorrect and can lead to data loss (such as on app quit). --- src/App/Document.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index bcbf6b3849..3b0ff5982f 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -2398,8 +2398,8 @@ private: Base::FileInfo tmp(sourcename); if (tmp.renameFile(targetname.c_str()) == false) { - Base::Console().Warning("Cannot rename file from '%s' to '%s'\n", - sourcename.c_str(), targetname.c_str()); + throw Base::FileException( + "Cannot rename tmp save file to project file", targetname); } } void applyTimeStamp(const std::string& sourcename, const std::string& targetname) { @@ -2531,9 +2531,8 @@ private: Base::FileInfo tmp(sourcename); if (tmp.renameFile(targetname.c_str()) == false) { - Base::Console().Error("Save interrupted: Cannot rename file from '%s' to '%s'\n", - sourcename.c_str(), targetname.c_str()); - //throw Base::FileException("Save interrupted: Cannot rename temporary file to project file", tmp); + throw Base::FileException( + "Save interrupted: Cannot rename temporary file to project file", tmp); } if (numberOfFiles <= 0) {