Fix console not staying open on minecraft crash
This commit is contained in:
parent
e611aef0e7
commit
fdc58bb913
@ -122,14 +122,15 @@ void ConsoleWindow::on_btnKillMinecraft_clicked()
|
|||||||
ui->btnKillMinecraft->setEnabled(true);
|
ui->btnKillMinecraft->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleWindow::onEnded(BaseInstance *instance)
|
void ConsoleWindow::onEnded(BaseInstance* instance, int code, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
ui->btnKillMinecraft->setEnabled(false);
|
ui->btnKillMinecraft->setEnabled(false);
|
||||||
|
|
||||||
// TODO: Might need an option to forcefully close, even on an error
|
|
||||||
if(instance->settings().get("AutoCloseConsole").toBool())
|
if(instance->settings().get("AutoCloseConsole").toBool())
|
||||||
{
|
{
|
||||||
// TODO: Check why this doesn't work
|
if (code == 0 && status != QProcess::CrashExit)
|
||||||
if (!proc->exitCode()) this->close();
|
{
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ private
|
|||||||
slots:
|
slots:
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
void on_btnKillMinecraft_clicked();
|
void on_btnKillMinecraft_clicked();
|
||||||
void onEnded(BaseInstance *instance);
|
void onEnded(BaseInstance *instance, int code, QProcess::ExitStatus status);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
@ -131,8 +131,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
view->installEventFilter(this);
|
view->installEventFilter(this);
|
||||||
|
|
||||||
proxymodel = new InstanceProxyModel(this);
|
proxymodel = new InstanceProxyModel(this);
|
||||||
// proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
// proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
||||||
//proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
// proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
||||||
// proxymodel->setDynamicSortFilter ( true );
|
// proxymodel->setDynamicSortFilter ( true );
|
||||||
|
|
||||||
// FIXME: instList should be global-ish, or at least not tied to the main window...
|
// FIXME: instList should be global-ish, or at least not tied to the main window...
|
||||||
@ -422,7 +422,7 @@ void MainWindow::on_actionSettings_triggered()
|
|||||||
{
|
{
|
||||||
SettingsDialog dialog(this);
|
SettingsDialog dialog(this);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
//FIXME: quick HACK to make this work. improve, optimize.
|
// FIXME: quick HACK to make this work. improve, optimize.
|
||||||
proxymodel->invalidate();
|
proxymodel->invalidate();
|
||||||
proxymodel->sort(0);
|
proxymodel->sort(0);
|
||||||
}
|
}
|
||||||
@ -725,7 +725,8 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
|||||||
|
|
||||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
|
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
|
||||||
SLOT(write(QString, MessageLevel::Enum)));
|
SLOT(write(QString, MessageLevel::Enum)));
|
||||||
connect(proc, SIGNAL(ended(BaseInstance *)), this, SLOT(instanceEnded(BaseInstance *)));
|
connect(proc, SIGNAL(ended(BaseInstance *, int, ExitStatus)), this,
|
||||||
|
SLOT(instanceEnded(BaseInstance *, int, ExitStatus)));
|
||||||
|
|
||||||
if (instance->settings().get("ShowConsole").toBool())
|
if (instance->settings().get("ShowConsole").toBool())
|
||||||
{
|
{
|
||||||
@ -882,7 +883,7 @@ void MainWindow::on_actionEditInstNotes_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::instanceEnded(BaseInstance *instance)
|
void MainWindow::instanceEnded(BaseInstance *instance, int code, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
this->show();
|
this->show();
|
||||||
ui->actionLaunchInstance->setEnabled(m_selectedInstance);
|
ui->actionLaunchInstance->setEnabled(m_selectedInstance);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
#include "logic/lists/InstanceList.h"
|
#include "logic/lists/InstanceList.h"
|
||||||
#include "logic/net/LoginTask.h"
|
#include "logic/net/LoginTask.h"
|
||||||
@ -115,7 +116,7 @@ slots:
|
|||||||
|
|
||||||
void on_actionChangeInstLWJGLVersion_triggered();
|
void on_actionChangeInstLWJGLVersion_triggered();
|
||||||
|
|
||||||
void instanceEnded(BaseInstance *instance);
|
void instanceEnded(BaseInstance *instance, int code, QProcess::ExitStatus status);
|
||||||
|
|
||||||
void on_actionInstanceSettings_triggered();
|
void on_actionInstanceSettings_triggered();
|
||||||
|
|
||||||
|
@ -111,19 +111,24 @@ void MinecraftProcess::on_stdOut()
|
|||||||
// exit handler
|
// exit handler
|
||||||
void MinecraftProcess::finish(int code, ExitStatus status)
|
void MinecraftProcess::finish(int code, ExitStatus status)
|
||||||
{
|
{
|
||||||
if (status != NormalExit)
|
|
||||||
{
|
|
||||||
// TODO: error handling
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Localization
|
|
||||||
|
|
||||||
if (!killed)
|
if (!killed)
|
||||||
//: Message displayed on instance exit
|
{
|
||||||
emit log(tr("Minecraft exited with exitcode %1.").arg(status));
|
if (status == NormalExit)
|
||||||
|
{
|
||||||
|
//: Message displayed on instance exit
|
||||||
|
emit log(tr("Minecraft exited with exitcode %1.").arg(code));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//: Message displayed on instance crashed
|
||||||
|
emit log(tr("Minecraft crashed with exitcode %1.").arg(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
//: Message displayed after the instance exits due to kill request
|
//: Message displayed after the instance exits due to kill request
|
||||||
emit log(tr("Minecraft was killed by user."), MessageLevel::Error);
|
emit log(tr("Minecraft was killed by user."), MessageLevel::Error);
|
||||||
|
}
|
||||||
|
|
||||||
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
|
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
|
||||||
|
|
||||||
@ -138,7 +143,7 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_instance->cleanupAfterRun();
|
m_instance->cleanupAfterRun();
|
||||||
emit ended(m_instance);
|
emit ended(m_instance, code, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProcess::killMinecraft()
|
void MinecraftProcess::killMinecraft()
|
||||||
|
@ -74,7 +74,7 @@ signals:
|
|||||||
/**
|
/**
|
||||||
* @brief emitted when mc has finished and the PostLaunchCommand was run
|
* @brief emitted when mc has finished and the PostLaunchCommand was run
|
||||||
*/
|
*/
|
||||||
void ended(BaseInstance *);
|
void ended(BaseInstance *, int code, ExitStatus status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief emitted when we want to log something
|
* @brief emitted when we want to log something
|
||||||
|
Loading…
Reference in New Issue
Block a user