aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
Diffstat (limited to 'launcher')
-rw-r--r--launcher/Application.cpp24
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp5
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp16
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp5
4 files changed, 35 insertions, 15 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index e33df252..0ce80d4b 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -294,16 +294,20 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
}
else
{
-#ifdef LAUNCHER_LINUX_DATADIR
- QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME"));
- if (xdgDataHome.isEmpty())
- xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
- dataPath = xdgDataHome + "/polymc";
- adjustedBy += "XDG standard " + dataPath;
-#elif defined(Q_OS_MAC)
+#if !defined(LAUNCHER_PORTABLE) || defined(Q_OS_MAC)
QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
dataPath = foo.absolutePath();
- adjustedBy += "Fallback to special Mac location " + dataPath;
+ adjustedBy += dataPath;
+
+#ifdef Q_OS_LINUX
+ // TODO: this should be removed in a future version
+ // TODO: provide a migration path similar to macOS migration
+ QDir bar(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), "polymc"));
+ if (bar.exists()) {
+ dataPath = bar.absolutePath();
+ adjustedBy += "Legacy data path " + dataPath;
+ }
+#endif
#else
dataPath = applicationDirPath();
adjustedBy += "Fallback to binary path " + dataPath;
@@ -505,8 +509,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
#elif defined(Q_OS_WIN32)
m_rootPath = binPath;
#elif defined(Q_OS_MAC)
- QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
+ QDir foo(FS::PathCombine(binPath, "../.."));
m_rootPath = foo.absolutePath();
+ // on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues)
+ FS::updateTimestamp(m_rootPath);
#endif
#ifdef MULTIMC_JARS_LOCATION
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index 6d33a6ac..114ac907 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -118,7 +118,10 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
.arg(addonId),
response));
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response] {
+ QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId] {
+ if(addonId != current.addonId){
+ return; //wrong request
+ }
QJsonParseError parse_error;
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
index 1138a298..7e6ac2fd 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
@@ -109,13 +109,16 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
if (current.versionsLoaded == false)
{
qDebug() << "Loading flame modpack versions";
- NetJob *netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
- std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
+ auto netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
+ auto response = new QByteArray();
int addonId = current.addonId;
- netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response.get()));
+ netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response));
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response]
+ QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]
{
+ if(addonId != current.addonId){
+ return; //wrong request
+ }
QJsonParseError parse_error;
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
if(parse_error.error != QJsonParseError::NoError) {
@@ -140,6 +143,11 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
suggestCurrent();
});
+ QObject::connect(netJob, &NetJob::finished, this, [response, netJob]
+ {
+ netJob->deleteLater();
+ delete response;
+ });
netJob->start();
}
else
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index fc6aff96..35cd743a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -103,7 +103,10 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId),
response));
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response] {
+ QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId] {
+ if(addonId != current.addonId){
+ return;
+ }
QJsonParseError parse_error;
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {