diff --git a/src/libs/utils/savefile.cpp b/src/libs/utils/savefile.cpp index 57750f252cb..ebd310d6794 100644 --- a/src/libs/utils/savefile.cpp +++ b/src/libs/utils/savefile.cpp @@ -31,6 +31,11 @@ #include "savefile.h" #include "qtcassert.h" #include "fileutils.h" +#ifdef Q_OS_WIN +# include +#else +# include +#endif namespace Utils { @@ -78,6 +83,15 @@ bool SaveFile::commit() QTC_ASSERT(!m_finalized, return false); m_finalized = true; + if (!flush()) { + remove(); + return false; + } +#ifdef Q_OS_WIN + FlushFileBuffers(handle()); +#else + fdatasync(handle()); +#endif close(); if (error() != NoError) { remove();