diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-02-28 10:20:25 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-02 21:56:25 +0200 |
commit | 5ff2681da6b00425056d11fb4f2caf64b4fcac97 (patch) | |
tree | 55f44449dabdb33043fb5ca2cb6877566d9e0a02 | |
parent | 5359f4499a298f8997d839804cc2497882551125 (diff) | |
download | MultiMC-5ff2681da6b00425056d11fb4f2caf64b4fcac97.tar MultiMC-5ff2681da6b00425056d11fb4f2caf64b4fcac97.tar.gz MultiMC-5ff2681da6b00425056d11fb4f2caf64b4fcac97.tar.lz MultiMC-5ff2681da6b00425056d11fb4f2caf64b4fcac97.tar.xz MultiMC-5ff2681da6b00425056d11fb4f2caf64b4fcac97.zip |
NOISSUE use QSaveFile for saving patch order
-rw-r--r-- | logic/minecraft/ProfileUtils.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp index 48e73472..bae34dbf 100644 --- a/logic/minecraft/ProfileUtils.cpp +++ b/logic/minecraft/ProfileUtils.cpp @@ -6,6 +6,7 @@ #include <QJsonDocument> #include <QJsonArray> #include <QRegularExpression> +#include <QSaveFile> namespace ProfileUtils { @@ -22,14 +23,25 @@ bool writeOverrideOrders(QString path, const PatchOrder &order) orderArray.append(str); } obj.insert("order", orderArray); - QFile orderFile(path); + QSaveFile orderFile(path); if (!orderFile.open(QFile::WriteOnly)) { QLOG_ERROR() << "Couldn't open" << orderFile.fileName() << "for writing:" << orderFile.errorString(); return false; } - orderFile.write(QJsonDocument(obj).toJson(QJsonDocument::Indented)); + auto data = QJsonDocument(obj).toJson(QJsonDocument::Indented); + if(orderFile.write(data) != data.size()) + { + qCritical() << "Couldn't write all the data into" << orderFile.fileName() + << "because:" << orderFile.errorString(); + return false; + } + if(!orderFile.commit()) + { + qCritical() << "Couldn't save" << orderFile.fileName() + << "because:" << orderFile.errorString(); + } return true; } |