Skip to content
Snippets Groups Projects
Commit f1d0c375 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Joerg Bornemann
Browse files

properly sync file's data on commit


this ensures that creator doesn't eat my config files on every crash.

Change-Id: I18f8135158e17d064774a49fe170b63c89517e49
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@nokia.com>
parent 95896519
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,11 @@
#include "savefile.h"
#include "qtcassert.h"
#include "fileutils.h"
#ifdef Q_OS_WIN
# include <windows.h>
#else
# include <unistd.h>
#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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment