From e29523ec0dbc207dbb15a6d227f7ced307276382 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Tue, 20 Jan 2026 15:57:52 +0500 Subject: [PATCH] refactor+fix: do not delete LaunchController before we're done using it, unify code for handling LaunchController finishing Signed-off-by: Octol1ttle (cherry picked from commit 4b72870d495f5cd157c1a5ba9310dc769dbe9d8c) --- launcher/Application.cpp | 36 +++++++----------------------------- launcher/Application.h | 3 +-- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index ae44d3238..cb8c8c625 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1564,9 +1564,7 @@ bool Application::launch(InstancePtr instance, } else if (m_mainWindow) { controller->setParentWidget(m_mainWindow); } - connect(controller.get(), &LaunchController::succeeded, this, &Application::controllerSucceeded); - connect(controller.get(), &LaunchController::failed, this, &Application::controllerFailed); - connect(controller.get(), &LaunchController::aborted, this, [this] { controllerFailed(tr("Aborted")); }); + connect(controller.get(), &LaunchController::finished, this, &Application::controllerFinished); addRunningInstance(); QMetaObject::invokeMethod(controller.get(), &Task::start, Qt::QueuedConnection); return true; @@ -1638,7 +1636,7 @@ void Application::updateIsRunning(bool running) m_updateRunning = running; } -void Application::controllerSucceeded() +void Application::controllerFinished() { auto controller = qobject_cast(sender()); if (!controller) @@ -1646,10 +1644,11 @@ void Application::controllerSucceeded() auto id = controller->id(); QMutexLocker locker(&m_instanceExtrasMutex); - auto& extras = m_instanceExtras[id]; + auto& extras = m_instanceExtras.at(id); + const bool wasSuccessful = controller->wasSuccessful(); // on success, do... - if (controller->instance()->settings()->get("AutoCloseConsole").toBool()) { + if (wasSuccessful && controller->instance()->settings()->get("AutoCloseConsole").toBool()) { if (extras.window) { QMetaObject::invokeMethod(extras.window, &QWidget::close, Qt::QueuedConnection); } @@ -1659,29 +1658,8 @@ void Application::controllerSucceeded() // quit when there are no more windows. if (shouldExitNow()) { - m_status = Status::Succeeded; - exit(0); - } -} - -void Application::controllerFailed(const QString& error) -{ - Q_UNUSED(error); - auto controller = qobject_cast(sender()); - if (!controller) - return; - auto id = controller->id(); - QMutexLocker locker(&m_instanceExtrasMutex); - auto& extras = m_instanceExtras[id]; - - // on failure, do... nothing - extras.controller.reset(); - subRunningInstance(); - - // quit when there are no more windows. - if (shouldExitNow()) { - m_status = Status::Failed; - exit(1); + m_status = wasSuccessful ? Succeeded : Failed; + exit(wasSuccessful ? 0 : 1); } } diff --git a/launcher/Application.h b/launcher/Application.h index 0fd733b50..134dc8b91 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -221,8 +221,7 @@ class Application : public QApplication { private slots: void on_windowClose(); void messageReceived(const QByteArray& message); - void controllerSucceeded(); - void controllerFailed(const QString& error); + void controllerFinished(); void setupWizardFinished(int status); private: