forked from qt-creator/qt-creator
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: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
committed by
Joerg Bornemann
parent
9589651999
commit
f1d0c37565
@@ -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();
|
||||
|
Reference in New Issue
Block a user