diff options
-rw-r--r-- | gui/ConsoleWindow.cpp | 9 | ||||
-rw-r--r-- | gui/ConsoleWindow.h | 2 | ||||
-rw-r--r-- | gui/MainWindow.cpp | 11 | ||||
-rw-r--r-- | gui/MainWindow.h | 3 | ||||
-rw-r--r-- | logic/MinecraftProcess.cpp | 23 | ||||
-rw-r--r-- | logic/MinecraftProcess.h | 2 |
6 files changed, 29 insertions, 21 deletions
diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index ec25b9cf..a3f294e6 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -122,14 +122,15 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() ui->btnKillMinecraft->setEnabled(true); } -void ConsoleWindow::onEnded(BaseInstance *instance) +void ConsoleWindow::onEnded(BaseInstance* instance, int code, QProcess::ExitStatus status) { ui->btnKillMinecraft->setEnabled(false); - // TODO: Might need an option to forcefully close, even on an error if(instance->settings().get("AutoCloseConsole").toBool()) { - // TODO: Check why this doesn't work - if (!proc->exitCode()) this->close(); + if (code == 0 && status != QProcess::CrashExit) + { + this->close(); + } } } diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h index 0ed35554..65786c7e 100644 --- a/gui/ConsoleWindow.h +++ b/gui/ConsoleWindow.h @@ -66,7 +66,7 @@ private slots: void on_closeButton_clicked(); void on_btnKillMinecraft_clicked(); - void onEnded(BaseInstance *instance); + void onEnded(BaseInstance *instance, int code, QProcess::ExitStatus status); protected: void closeEvent(QCloseEvent *); diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 62ae195b..c0815d18 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -131,8 +131,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi view->installEventFilter(this); proxymodel = new InstanceProxyModel(this); -// proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole); - //proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole); + // proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole); + // proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole); // proxymodel->setDynamicSortFilter ( true ); // 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); dialog.exec(); - //FIXME: quick HACK to make this work. improve, optimize. + // FIXME: quick HACK to make this work. improve, optimize. proxymodel->invalidate(); proxymodel->sort(0); } @@ -725,7 +725,8 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response) connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, 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()) { @@ -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(); ui->actionLaunchInstance->setEnabled(m_selectedInstance); diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 97aa0d9f..798df0f9 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -16,6 +16,7 @@ #pragma once #include <QMainWindow> +#include <QProcess> #include "logic/lists/InstanceList.h" #include "logic/net/LoginTask.h" @@ -115,7 +116,7 @@ slots: void on_actionChangeInstLWJGLVersion_triggered(); - void instanceEnded(BaseInstance *instance); + void instanceEnded(BaseInstance *instance, int code, QProcess::ExitStatus status); void on_actionInstanceSettings_triggered(); diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index ff122628..6c86c73a 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -111,19 +111,24 @@ void MinecraftProcess::on_stdOut() // exit handler void MinecraftProcess::finish(int code, ExitStatus status) { - if (status != NormalExit) + if (!killed) { - // TODO: error handling + 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)); + } } - - // TODO: Localization - - if (!killed) - //: Message displayed on instance exit - emit log(tr("Minecraft exited with exitcode %1.").arg(status)); else + { //: Message displayed after the instance exits due to kill request emit log(tr("Minecraft was killed by user."), MessageLevel::Error); + } m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code)); @@ -138,7 +143,7 @@ void MinecraftProcess::finish(int code, ExitStatus status) } } m_instance->cleanupAfterRun(); - emit ended(m_instance); + emit ended(m_instance, code, status); } void MinecraftProcess::killMinecraft() diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h index ad887c5b..2a61e172 100644 --- a/logic/MinecraftProcess.h +++ b/logic/MinecraftProcess.h @@ -74,7 +74,7 @@ signals: /** * @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 |