GH-1642 fix instance launch from console

This commit is contained in:
Petr Mrázek 2016-08-09 22:29:17 +02:00
parent 877d1020db
commit 74b4343c43
6 changed files with 17 additions and 6 deletions

View File

@ -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()));

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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();
}