diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-03-15 09:02:56 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-03-15 09:02:56 +0100 |
commit | a74f3b553ab3294e153d73366294e7c8fbc2372f (patch) | |
tree | a178043eae21f258dc9d4733f2fe2e28d8d079fe /logic/MinecraftProcess.cpp | |
parent | de2eb3fc5404cbbfd438919c250885e5e8450a82 (diff) | |
download | MultiMC-a74f3b553ab3294e153d73366294e7c8fbc2372f.tar MultiMC-a74f3b553ab3294e153d73366294e7c8fbc2372f.tar.gz MultiMC-a74f3b553ab3294e153d73366294e7c8fbc2372f.tar.lz MultiMC-a74f3b553ab3294e153d73366294e7c8fbc2372f.tar.xz MultiMC-a74f3b553ab3294e153d73366294e7c8fbc2372f.zip |
Remove the timeout for pre/post commands. Fixes #107
Diffstat (limited to 'logic/MinecraftProcess.cpp')
-rw-r--r-- | logic/MinecraftProcess.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index effa1095..2dd40e99 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -259,7 +259,14 @@ void MinecraftProcess::finish(int code, ExitStatus status) void MinecraftProcess::killMinecraft() { killed = true; - kill(); + if (m_prepostlaunchprocess.state() == QProcess::Running) + { + m_prepostlaunchprocess.kill(); + } + else + { + kill(); + } } bool MinecraftProcess::preLaunch() @@ -271,8 +278,10 @@ bool MinecraftProcess::preLaunch() // Launch emit log(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd)); m_prepostlaunchprocess.start(prelaunch_cmd); - // Wait - m_prepostlaunchprocess.waitForFinished(); + if (!waitForPrePost()) + { + return false; + } // Flush console window if (!m_err_leftover.isEmpty()) { @@ -310,7 +319,10 @@ bool MinecraftProcess::postLaunch() postlaunch_cmd = substituteVariables(postlaunch_cmd); emit log(tr("Running Post-Launch command: %1").arg(postlaunch_cmd)); m_prepostlaunchprocess.start(postlaunch_cmd); - m_prepostlaunchprocess.waitForFinished(); + if (!waitForPrePost()) + { + return false; + } // Flush console window if (!m_err_leftover.isEmpty()) { @@ -338,6 +350,23 @@ bool MinecraftProcess::postLaunch() return true; } +bool MinecraftProcess::waitForPrePost() +{ + m_prepostlaunchprocess.waitForStarted(); + QEventLoop eventLoop; + auto finisher = [this, &eventLoop](QProcess::ProcessState state) + { + if (state == QProcess::NotRunning) + { + eventLoop.quit(); + } + }; + auto connection = connect(&m_prepostlaunchprocess, &QProcess::stateChanged, finisher); + int ret = eventLoop.exec(); + disconnect(connection); + return ret == 0; +} + QMap<QString, QString> MinecraftProcess::getVariables() const { QMap<QString, QString> out; |