1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
sudden6 2016-03-24 01:10:09 +01:00
parent 252c9c8fae
commit 9a80950ac6
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 25 additions and 4 deletions

View File

@ -332,8 +332,18 @@ void Profile::saveToxSave(QByteArray data)
}
saveFile.write(data);
saveFile.commit();
newProfile = false;
// check if everything got written
if(saveFile.flush())
{
saveFile.commit();
newProfile = false;
}
else
{
saveFile.cancelWriting();
qCritical() << "Failed to write, can't save!";
}
}
QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)

View File

@ -22,6 +22,7 @@
#include "src/nexus.h"
#include "src/persistence/profile.h"
#include "src/core/core.h"
#include <QSaveFile>
#include <QFile>
#include <QDebug>
#include <memory>
@ -219,7 +220,7 @@ void SettingsSerializer::load()
void SettingsSerializer::save()
{
QFile f(path);
QSaveFile f(path);
if (!f.open(QIODevice::Truncate | QIODevice::WriteOnly))
{
qWarning() << "Couldn't open file";
@ -280,7 +281,17 @@ void SettingsSerializer::save()
}
f.write(data);
f.close();
// check if everything got written
if(f.flush())
{
f.commit();
}
else
{
f.cancelWriting();
qCritical() << "Failed to write, can't save!";
}
}
void SettingsSerializer::readSerialized()