diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/auth/MojangAccountList.cpp | 11 | ||||
-rw-r--r-- | logic/lists/InstanceList.cpp | 7 | ||||
-rw-r--r-- | logic/lists/InstanceList.h | 3 |
3 files changed, 20 insertions, 1 deletions
diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp index 841552f5..33990662 100644 --- a/logic/auth/MojangAccountList.cpp +++ b/logic/auth/MojangAccountList.cpp @@ -22,6 +22,7 @@ #include <QJsonArray> #include <QJsonObject> #include <QJsonParseError> +#include <QDir> #include "logger/QsLog.h" @@ -264,6 +265,11 @@ bool MojangAccountList::loadList(const QString &filePath) return false; } + if (!QDir::current().exists(path)) + { + QDir::current().mkpath(path); + } + QFile file(path); // Try to open the file and fail if we can't. @@ -345,6 +351,11 @@ bool MojangAccountList::saveList(const QString &filePath) return false; } + if (!QDir::current().exists(path)) + { + QDir::current().mkpath(path); + } + QLOG_INFO() << "Writing account list to" << path; QLOG_DEBUG() << "Building JSON data structure."; diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index b9595578..94481fb9 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -36,11 +36,16 @@ const static int GROUP_FILE_FORMAT_VERSION = 1; InstanceList::InstanceList(const QString &instDir, QObject *parent) : QAbstractListModel(parent), m_instDir(instDir) { + connect(MMC, &MultiMC::aboutToQuit, this, &InstanceList::saveGroupList); + + if (!QDir::current().exists(m_instDir)) + { + QDir::current().mkpath(m_instDir); + } } InstanceList::~InstanceList() { - saveGroupList(); } int InstanceList::rowCount(const QModelIndex &parent) const diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index 8cd39746..c3bb74cd 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -29,6 +29,9 @@ class InstanceList : public QAbstractListModel Q_OBJECT private: void loadGroupList(QMap<QString, QString> &groupList); + +private +slots: void saveGroupList(); public: |