Skip to content

Commit

Permalink
Merge branch 'PrismLauncher:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgars-Cirulis authored Nov 1, 2024
2 parents 8145701 + ba07a13 commit 727b45b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 88 deletions.
11 changes: 10 additions & 1 deletion launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "net/PasteUpload.h"
#include "pathmatcher/MultiMatcher.h"
#include "pathmatcher/SimplePrefixMatcher.h"
#include "tasks/Task.h"
#include "tools/GenericProfiler.h"
#include "ui/InstanceWindow.h"
#include "ui/MainWindow.h"
Expand Down Expand Up @@ -1397,6 +1398,7 @@ bool Application::launch(InstancePtr instance,
if (m_updateRunning) {
qDebug() << "Cannot launch instances while an update is running. Please try again when updates are completed.";
} else if (instance->canLaunch()) {
QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[instance->id()];
auto window = extras.window;
if (window) {
Expand All @@ -1422,7 +1424,7 @@ bool Application::launch(InstancePtr instance,
connect(controller.get(), &LaunchController::failed, this, &Application::controllerFailed);
connect(controller.get(), &LaunchController::aborted, this, [this] { controllerFailed(tr("Aborted")); });
addRunningInstance();
controller->start();
QMetaObject::invokeMethod(controller.get(), &Task::start, Qt::QueuedConnection);
return true;
} else if (instance->isRunning()) {
showInstanceWindow(instance, "console");
Expand All @@ -1440,9 +1442,11 @@ bool Application::kill(InstancePtr instance)
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
return false;
}
QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[instance->id()];
// NOTE: copy of the shared pointer keeps it alive
auto controller = extras.controller;
locker.unlock();
if (controller) {
return controller->abort();
}
Expand Down Expand Up @@ -1496,6 +1500,8 @@ void Application::controllerSucceeded()
if (!controller)
return;
auto id = controller->id();

QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[id];

// on success, do...
Expand All @@ -1521,6 +1527,7 @@ void Application::controllerFailed(const QString& error)
if (!controller)
return;
auto id = controller->id();
QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[id];

// on failure, do... nothing
Expand Down Expand Up @@ -1578,6 +1585,7 @@ InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString pa
if (!instance)
return nullptr;
auto id = instance->id();
QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[id];
auto& window = extras.window;

Expand Down Expand Up @@ -1615,6 +1623,7 @@ void Application::on_windowClose()
m_openWindows--;
auto instWindow = qobject_cast<InstanceWindow*>(QObject::sender());
if (instWindow) {
QMutexLocker locker(&m_instanceExtrasMutex);
auto& extras = m_instanceExtras[instWindow->instanceId()];
extras.window = nullptr;
if (extras.controller) {
Expand Down
1 change: 1 addition & 0 deletions launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class Application : public QApplication {
shared_qobject_ptr<LaunchController> controller;
};
std::map<QString, InstanceXtras> m_instanceExtras;
mutable QMutex m_instanceExtrasMutex;

// main state variables
size_t m_openWindows = 0;
Expand Down
4 changes: 2 additions & 2 deletions launcher/SysInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ QString getSupportedJavaArchitecture()
if (arch == "arm64")
return "mac-os-arm64";
if (arch.contains("64"))
return "mac-os-64";
return "mac-os-x64";
if (arch.contains("86"))
return "mac-os-86";
return "mac-os-x86";
// Unknown, maybe something new, appending arch
return "mac-os-" + arch;
} else if (sys == "linux") {
Expand Down
85 changes: 0 additions & 85 deletions launcher/minecraft/mod/tasks/BasicFolderLoadTask.h

This file was deleted.

0 comments on commit 727b45b

Please sign in to comment.