mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
Fix ZeldaZach review for PR 7492: preserve printing in DeckDiff::merge, atomic sidecar save with QSaveFile
This commit is contained in:
parent
1e97ab086b
commit
473b255959
3 changed files with 76 additions and 21 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QSaveFile>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
@ -63,12 +64,12 @@ bool DeckSyncSidecar::save() const
|
|||
root.insert("records", records);
|
||||
|
||||
QDir().mkpath(QFileInfo(filePath).absolutePath());
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
QSaveFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
return false;
|
||||
}
|
||||
file.write(QJsonDocument(root).toJson(QJsonDocument::Compact));
|
||||
return true;
|
||||
return file.commit();
|
||||
}
|
||||
|
||||
bool DeckSyncSidecar::contains(const QString &relativePath) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue