From 74b4343c43cb0f3fc85cf27d1159349d0b3f32e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 9 Aug 2016 22:29:17 +0200 Subject: GH-1642 fix instance launch from console --- application/InstanceWindow.cpp | 5 +++++ application/InstanceWindow.h | 7 ++++++- application/LaunchInteraction.cpp | 2 ++ application/MultiMC.cpp | 4 ++++ application/main.cpp | 4 ---- 5 files changed, 17 insertions(+), 5 deletions(-) (limited to 'application') diff --git a/application/InstanceWindow.cpp b/application/InstanceWindow.cpp index dfc7b815..0b9d7019 100644 --- a/application/InstanceWindow.cpp +++ b/application/InstanceWindow.cpp @@ -157,6 +157,11 @@ void InstanceWindow::closeEvent(QCloseEvent *event) { emit isClosing(); event->accept(); + if(m_shouldQuit) + { + // this needs to be delayed so we don't do horrible things + QMetaObject::invokeMethod(MMC, "quit", Qt::QueuedConnection); + } } } diff --git a/application/InstanceWindow.h b/application/InstanceWindow.h index 7ffc4142..db84b9be 100644 --- a/application/InstanceWindow.h +++ b/application/InstanceWindow.h @@ -36,6 +36,11 @@ public: QString instanceId(); + void setQuitOnClose(bool shouldQuit = false) + { + m_shouldQuit = shouldQuit; + } + signals: void isClosing(); @@ -61,7 +66,7 @@ private: std::shared_ptr m_proc; unique_qobject_ptr m_launchController; InstancePtr m_instance; - bool m_mayclose = true; + bool m_shouldQuit = false; PageContainer *m_container = nullptr; QPushButton *m_closeButton = nullptr; QPushButton *m_killButton = nullptr; diff --git a/application/LaunchInteraction.cpp b/application/LaunchInteraction.cpp index 80a3368d..0b601d49 100644 --- a/application/LaunchInteraction.cpp +++ b/application/LaunchInteraction.cpp @@ -217,7 +217,9 @@ void LaunchController::launchInstance() } else { + // this is used when launching directly from command line m_console = new InstanceWindow(m_instance); + m_console->setQuitOnClose(true); } connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch); diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 4b1447d9..f53d05e1 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -219,6 +219,10 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar } qDebug() << "Binary path : " << binPath; qDebug() << "Application root path : " << rootPath; + if(!launchId.isEmpty()) + { + qDebug() << "ID of instance to launch : " << launchId; + } // load settings initGlobalSettings(test_mode); diff --git a/application/main.cpp b/application/main.cpp index a8951d33..6b0c361b 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -22,10 +22,6 @@ int launchInstance(MultiMC &app, InstancePtr inst) launchController.setInstance(inst); launchController.setOnline(true); QMetaObject::invokeMethod(&launchController, "start", Qt::QueuedConnection); - app.connect(&launchController, &Task::finished, [&app]() - { - app.quit(); - }); return app.exec(); } -- cgit v1.2.3