diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp index 48e73472d..bae34dbfb 100644 --- a/logic/minecraft/ProfileUtils.cpp +++ b/logic/minecraft/ProfileUtils.cpp @@ -6,6 +6,7 @@ #include #include #include +#include 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; }