summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-12-05 09:52:04 +0100
committerPetr Mrázek <peterix@gmail.com>2017-12-05 09:52:04 +0100
commit6d034bda825c506bede7bf0229f47095222edfc2 (patch)
treee305701ed2eb2afb080ade007d3fe1668f1cfa4e
parent44475350ebfed97f6b0cb14c1e62c8ef67fb9a31 (diff)
downloadMultiMC-6d034bda825c506bede7bf0229f47095222edfc2.tar
MultiMC-6d034bda825c506bede7bf0229f47095222edfc2.tar.gz
MultiMC-6d034bda825c506bede7bf0229f47095222edfc2.tar.lz
MultiMC-6d034bda825c506bede7bf0229f47095222edfc2.tar.xz
MultiMC-6d034bda825c506bede7bf0229f47095222edfc2.zip
GH-2059 fix instance directory not being created on first launch
-rw-r--r--api/logic/FolderInstanceProvider.cpp9
-rw-r--r--api/logic/InstanceList.cpp5
-rw-r--r--api/logic/InstanceList.h6
-rw-r--r--application/MultiMC.cpp4
4 files changed, 10 insertions, 14 deletions
diff --git a/api/logic/FolderInstanceProvider.cpp b/api/logic/FolderInstanceProvider.cpp
index 296b366e..74ac456a 100644
--- a/api/logic/FolderInstanceProvider.cpp
+++ b/api/logic/FolderInstanceProvider.cpp
@@ -34,12 +34,13 @@ struct WatchLock
FolderInstanceProvider::FolderInstanceProvider(SettingsObjectPtr settings, const QString& instDir)
: BaseInstanceProvider(settings)
{
- // Normalize path
- m_instDir = QDir(instDir).canonicalPath();
- if (!QDir::current().exists(m_instDir))
+ // Create aand normalize path
+ if (!QDir::current().exists(instDir))
{
- QDir::current().mkpath(m_instDir);
+ QDir::current().mkpath(instDir);
}
+ // NOTE: canonicalPath requires the path to exist. Do not move this above the creation block!
+ m_instDir = QDir(instDir).canonicalPath();
m_watcher = new QFileSystemWatcher(this);
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &FolderInstanceProvider::instanceDirContentsChanged);
m_watcher->addPath(m_instDir);
diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp
index 96251b60..d5b71d50 100644
--- a/api/logic/InstanceList.cpp
+++ b/api/logic/InstanceList.cpp
@@ -26,10 +26,9 @@
#include "FolderInstanceProvider.h"
-InstanceList::InstanceList(SettingsObjectPtr globalSettings, const QString &instDir, QObject *parent)
- : QAbstractListModel(parent), m_instDir(instDir)
+InstanceList::InstanceList(QObject *parent)
+ : QAbstractListModel(parent)
{
- m_globalSettings = globalSettings;
resumeWatch();
}
diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h
index 89be10de..dceca043 100644
--- a/api/logic/InstanceList.h
+++ b/api/logic/InstanceList.h
@@ -27,16 +27,14 @@
#include "QObjectPtr.h"
-class QFileSystemWatcher;
class BaseInstance;
-class QDir;
class MULTIMC_LOGIC_EXPORT InstanceList : public QAbstractListModel
{
Q_OBJECT
public:
- explicit InstanceList(SettingsObjectPtr globalSettings, const QString &instDir, QObject *parent = 0);
+ explicit InstanceList(QObject *parent = 0);
virtual ~InstanceList();
public:
@@ -101,9 +99,7 @@ private:
protected:
int m_watchLevel = 0;
QSet<BaseInstanceProvider *> m_updatedProviders;
- QString m_instDir;
QList<InstancePtr> m_instances;
QSet<QString> m_groups;
- SettingsObjectPtr m_globalSettings;
QVector<shared_qobject_ptr<BaseInstanceProvider>> m_providers;
};
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 7fce31d0..e8309ceb 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -584,13 +584,13 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
auto InstDirSetting = m_settings->getSetting("InstanceDir");
// instance path: check for problems with '!' in instance path and warn the user in the log
// and rememer that we have to show him a dialog when the gui starts (if it does so)
- QString instDir = m_settings->get("InstanceDir").toString();
+ QString instDir = InstDirSetting->get().toString();
qDebug() << "Instance path : " << instDir;
if (FS::checkProblemticPathJava(QDir(instDir)))
{
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems";
}
- m_instances.reset(new InstanceList(m_settings, InstDirSetting->get().toString(), this));
+ m_instances.reset(new InstanceList(this));
m_instanceFolder = new FolderInstanceProvider(m_settings, instDir);
connect(InstDirSetting.get(), &Setting::SettingChanged, m_instanceFolder, &FolderInstanceProvider::on_InstFolderChanged);
m_instances->addInstanceProvider(m_instanceFolder);