GH-1300 call application quit when direct launch instance quits
This commit is contained in:
parent
8a4fd8c468
commit
895d8ab469
@ -16,11 +16,11 @@
|
|||||||
#include <launch/steps/TextPrint.h>
|
#include <launch/steps/TextPrint.h>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
LaunchController::LaunchController(QObject *parent) : QObject(parent)
|
LaunchController::LaunchController(QObject *parent) : Task(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchController::launch()
|
void LaunchController::executeTask()
|
||||||
{
|
{
|
||||||
login();
|
login();
|
||||||
}
|
}
|
||||||
@ -29,7 +29,10 @@ void LaunchController::launch()
|
|||||||
void LaunchController::login()
|
void LaunchController::login()
|
||||||
{
|
{
|
||||||
if (!m_instance)
|
if (!m_instance)
|
||||||
|
{
|
||||||
|
emitFailed(tr("No instance specified"));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
|
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
|
||||||
|
|
||||||
@ -70,7 +73,10 @@ void LaunchController::login()
|
|||||||
|
|
||||||
// if no account is selected, we bail
|
// if no account is selected, we bail
|
||||||
if (!account.get())
|
if (!account.get())
|
||||||
|
{
|
||||||
|
emitFailed(tr("No account selected for launch"));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we try empty password first :)
|
// we try empty password first :)
|
||||||
QString password;
|
QString password;
|
||||||
@ -92,7 +98,9 @@ void LaunchController::login()
|
|||||||
// is still logged in.
|
// is still logged in.
|
||||||
ProgressDialog progDialog(m_parentWidget);
|
ProgressDialog progDialog(m_parentWidget);
|
||||||
if (m_online)
|
if (m_online)
|
||||||
|
{
|
||||||
progDialog.setSkipButton(true, tr("Play Offline"));
|
progDialog.setSkipButton(true, tr("Play Offline"));
|
||||||
|
}
|
||||||
progDialog.execWithTask(task.get());
|
progDialog.execWithTask(task.get());
|
||||||
if (!task->successful())
|
if (!task->successful())
|
||||||
{
|
{
|
||||||
@ -110,6 +118,7 @@ void LaunchController::login()
|
|||||||
{
|
{
|
||||||
qCritical() << "Received undetermined session status during login. Bye.";
|
qCritical() << "Received undetermined session status during login. Bye.";
|
||||||
tryagain = false;
|
tryagain = false;
|
||||||
|
emitFailed(tr("Received undetermined session status during login."));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AuthSession::RequiresPassword:
|
case AuthSession::RequiresPassword:
|
||||||
@ -169,9 +178,11 @@ void LaunchController::login()
|
|||||||
{
|
{
|
||||||
launchInstance();
|
launchInstance();
|
||||||
tryagain = false;
|
tryagain = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emitFailed(tr("Failed to launch."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchController::launchInstance()
|
void LaunchController::launchInstance()
|
||||||
@ -182,12 +193,14 @@ void LaunchController::launchInstance()
|
|||||||
if(!m_instance->reload())
|
if(!m_instance->reload())
|
||||||
{
|
{
|
||||||
QMessageBox::critical(m_parentWidget, tr("Error"), tr("Couldn't load the instance profile."));
|
QMessageBox::critical(m_parentWidget, tr("Error"), tr("Couldn't load the instance profile."));
|
||||||
|
emitFailed(tr("Couldn't load the instance profile."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_launcher = m_instance->createLaunchTask(m_session);
|
m_launcher = m_instance->createLaunchTask(m_session);
|
||||||
if (!m_launcher)
|
if (!m_launcher)
|
||||||
{
|
{
|
||||||
|
emitFailed(tr("Couldn't instantiate a launcher."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,4 +267,5 @@ void LaunchController::instanceEnded()
|
|||||||
{
|
{
|
||||||
m_parentWidget->show();
|
m_parentWidget->show();
|
||||||
}
|
}
|
||||||
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
#include <tools/BaseProfiler.h>
|
#include <tools/BaseProfiler.h>
|
||||||
|
|
||||||
class ConsoleWindow;
|
class ConsoleWindow;
|
||||||
class LaunchController: public QObject
|
class LaunchController: public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
virtual void executeTask();
|
||||||
|
|
||||||
LaunchController(QObject * parent = nullptr);
|
LaunchController(QObject * parent = nullptr);
|
||||||
virtual ~LaunchController(){};
|
virtual ~LaunchController(){};
|
||||||
|
|
||||||
@ -28,8 +30,6 @@ public:
|
|||||||
m_parentWidget = widget;
|
m_parentWidget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void launch();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void login();
|
void login();
|
||||||
void launchInstance();
|
void launchInstance();
|
||||||
|
@ -1498,7 +1498,7 @@ void MainWindow::launch(InstancePtr instance, bool online, BaseProfilerFactory *
|
|||||||
m_launchController->setOnline(online);
|
m_launchController->setOnline(online);
|
||||||
m_launchController->setParentWidget(this);
|
m_launchController->setParentWidget(this);
|
||||||
m_launchController->setProfiler(profiler);
|
m_launchController->setProfiler(profiler);
|
||||||
m_launchController->launch();
|
m_launchController->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::taskEnd()
|
void MainWindow::taskEnd()
|
||||||
|
@ -21,7 +21,11 @@ int launchInstance(MultiMC &app, InstancePtr inst)
|
|||||||
LaunchController launchController;
|
LaunchController launchController;
|
||||||
launchController.setInstance(inst);
|
launchController.setInstance(inst);
|
||||||
launchController.setOnline(true);
|
launchController.setOnline(true);
|
||||||
launchController.launch();
|
QMetaObject::invokeMethod(&launchController, "start", Qt::QueuedConnection);
|
||||||
|
app.connect(&launchController, &Task::finished, [&app]()
|
||||||
|
{
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user