mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #2161
This commit is contained in:
parent
252c9c8fae
commit
9a80950ac6
|
@ -332,8 +332,18 @@ void Profile::saveToxSave(QByteArray data)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile.write(data);
|
saveFile.write(data);
|
||||||
|
|
||||||
|
// check if everything got written
|
||||||
|
if(saveFile.flush())
|
||||||
|
{
|
||||||
saveFile.commit();
|
saveFile.commit();
|
||||||
newProfile = false;
|
newProfile = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
saveFile.cancelWriting();
|
||||||
|
qCritical() << "Failed to write, can't save!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)
|
QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "src/nexus.h"
|
#include "src/nexus.h"
|
||||||
#include "src/persistence/profile.h"
|
#include "src/persistence/profile.h"
|
||||||
#include "src/core/core.h"
|
#include "src/core/core.h"
|
||||||
|
#include <QSaveFile>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -219,7 +220,7 @@ void SettingsSerializer::load()
|
||||||
|
|
||||||
void SettingsSerializer::save()
|
void SettingsSerializer::save()
|
||||||
{
|
{
|
||||||
QFile f(path);
|
QSaveFile f(path);
|
||||||
if (!f.open(QIODevice::Truncate | QIODevice::WriteOnly))
|
if (!f.open(QIODevice::Truncate | QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
qWarning() << "Couldn't open file";
|
qWarning() << "Couldn't open file";
|
||||||
|
@ -280,7 +281,17 @@ void SettingsSerializer::save()
|
||||||
}
|
}
|
||||||
|
|
||||||
f.write(data);
|
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()
|
void SettingsSerializer::readSerialized()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user