mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-27 03:14:49 +00:00
GH-1642 fix instance launch from console
This commit is contained in:
parent
877d1020db
commit
74b4343c43
@ -344,7 +344,6 @@ InstanceList::InstListError InstanceList::loadList()
|
|||||||
m_instances.clear();
|
m_instances.clear();
|
||||||
for(auto inst: tempList)
|
for(auto inst: tempList)
|
||||||
{
|
{
|
||||||
inst->setParent(this);
|
|
||||||
connect(inst.get(), SIGNAL(propertiesChanged(BaseInstance *)), this,
|
connect(inst.get(), SIGNAL(propertiesChanged(BaseInstance *)), this,
|
||||||
SLOT(propertiesChanged(BaseInstance *)));
|
SLOT(propertiesChanged(BaseInstance *)));
|
||||||
connect(inst.get(), SIGNAL(groupChanged()), this, SLOT(groupChanged()));
|
connect(inst.get(), SIGNAL(groupChanged()), this, SLOT(groupChanged()));
|
||||||
|
@ -157,6 +157,11 @@ void InstanceWindow::closeEvent(QCloseEvent *event)
|
|||||||
{
|
{
|
||||||
emit isClosing();
|
emit isClosing();
|
||||||
event->accept();
|
event->accept();
|
||||||
|
if(m_shouldQuit)
|
||||||
|
{
|
||||||
|
// this needs to be delayed so we don't do horrible things
|
||||||
|
QMetaObject::invokeMethod(MMC, "quit", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,11 @@ public:
|
|||||||
|
|
||||||
QString instanceId();
|
QString instanceId();
|
||||||
|
|
||||||
|
void setQuitOnClose(bool shouldQuit = false)
|
||||||
|
{
|
||||||
|
m_shouldQuit = shouldQuit;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isClosing();
|
void isClosing();
|
||||||
|
|
||||||
@ -61,7 +66,7 @@ private:
|
|||||||
std::shared_ptr<LaunchTask> m_proc;
|
std::shared_ptr<LaunchTask> m_proc;
|
||||||
unique_qobject_ptr<LaunchController> m_launchController;
|
unique_qobject_ptr<LaunchController> m_launchController;
|
||||||
InstancePtr m_instance;
|
InstancePtr m_instance;
|
||||||
bool m_mayclose = true;
|
bool m_shouldQuit = false;
|
||||||
PageContainer *m_container = nullptr;
|
PageContainer *m_container = nullptr;
|
||||||
QPushButton *m_closeButton = nullptr;
|
QPushButton *m_closeButton = nullptr;
|
||||||
QPushButton *m_killButton = nullptr;
|
QPushButton *m_killButton = nullptr;
|
||||||
|
@ -217,7 +217,9 @@ void LaunchController::launchInstance()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// this is used when launching directly from command line
|
||||||
m_console = new InstanceWindow(m_instance);
|
m_console = new InstanceWindow(m_instance);
|
||||||
|
m_console->setQuitOnClose(true);
|
||||||
}
|
}
|
||||||
connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
||||||
|
|
||||||
|
@ -219,6 +219,10 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
|
|||||||
}
|
}
|
||||||
qDebug() << "Binary path : " << binPath;
|
qDebug() << "Binary path : " << binPath;
|
||||||
qDebug() << "Application root path : " << rootPath;
|
qDebug() << "Application root path : " << rootPath;
|
||||||
|
if(!launchId.isEmpty())
|
||||||
|
{
|
||||||
|
qDebug() << "ID of instance to launch : " << launchId;
|
||||||
|
}
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
initGlobalSettings(test_mode);
|
initGlobalSettings(test_mode);
|
||||||
|
@ -22,10 +22,6 @@ int launchInstance(MultiMC &app, InstancePtr inst)
|
|||||||
launchController.setInstance(inst);
|
launchController.setInstance(inst);
|
||||||
launchController.setOnline(true);
|
launchController.setOnline(true);
|
||||||
QMetaObject::invokeMethod(&launchController, "start", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(&launchController, "start", Qt::QueuedConnection);
|
||||||
app.connect(&launchController, &Task::finished, [&app]()
|
|
||||||
{
|
|
||||||
app.quit();
|
|
||||||
});
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user