summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-08-09 22:29:17 +0200
committerPetr Mrázek <peterix@gmail.com>2016-08-09 22:29:17 +0200
commit74b4343c43cb0f3fc85cf27d1159349d0b3f32e6 (patch)
tree5e32c9bfb0dc6f76e0404c581b3ca43a26ee3e35
parent877d1020db4acfd5085a27cad013b7d03177ba0b (diff)
downloadMultiMC-74b4343c43cb0f3fc85cf27d1159349d0b3f32e6.tar
MultiMC-74b4343c43cb0f3fc85cf27d1159349d0b3f32e6.tar.gz
MultiMC-74b4343c43cb0f3fc85cf27d1159349d0b3f32e6.tar.lz
MultiMC-74b4343c43cb0f3fc85cf27d1159349d0b3f32e6.tar.xz
MultiMC-74b4343c43cb0f3fc85cf27d1159349d0b3f32e6.zip
GH-1642 fix instance launch from console
-rw-r--r--api/logic/InstanceList.cpp1
-rw-r--r--application/InstanceWindow.cpp5
-rw-r--r--application/InstanceWindow.h7
-rw-r--r--application/LaunchInteraction.cpp2
-rw-r--r--application/MultiMC.cpp4
-rw-r--r--application/main.cpp4
6 files changed, 17 insertions, 6 deletions
diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp
index 783df660..d89b8ea7 100644
--- a/api/logic/InstanceList.cpp
+++ b/api/logic/InstanceList.cpp
@@ -344,7 +344,6 @@ InstanceList::InstListError InstanceList::loadList()
m_instances.clear();
for(auto inst: tempList)
{
- inst->setParent(this);
connect(inst.get(), SIGNAL(propertiesChanged(BaseInstance *)), this,
SLOT(propertiesChanged(BaseInstance *)));
connect(inst.get(), SIGNAL(groupChanged()), this, SLOT(groupChanged()));
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<LaunchTask> m_proc;
unique_qobject_ptr<LaunchController> 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();
}