diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-02 15:29:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-02 15:29:23 -0500 |
| commit | d5a4077a4396058a9f79339dba0c29c4b742b60f (patch) | |
| tree | a8f32d4aa0ec39600c32788c9022ea4559d408b6 /src/processrunner.cpp | |
| parent | eabca00c35d7af3b6822bb7857ef1e073807ca0a (diff) | |
| parent | 3b78e436dbee043e4a3f81e5bfa09695c2a708c4 (diff) | |
Merge pull request #915 from isanae/lock-hook-shell
Lock, hook, shell
Diffstat (limited to 'src/processrunner.cpp')
| -rw-r--r-- | src/processrunner.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 89777072..46065d69 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -3,6 +3,8 @@ #include "instancemanager.h" #include "iuserinterface.h" #include "envmodule.h" +#include "env.h" +#include <iplugingame.h> #include <log.h> using namespace MOBase; @@ -473,13 +475,14 @@ ProcessRunner& ProcessRunner::setWaitForCompletion( return *this; } -ProcessRunner& ProcessRunner::setFromFile(QWidget* parent, const QFileInfo& targetInfo) +ProcessRunner& ProcessRunner::setFromFile( + QWidget* parent, const QFileInfo& targetInfo, bool forceHook) { if (!parent && m_ui) { parent = m_ui->qtWidget(); } - // if the file is a .exe, start it directory; if it's anything else, ask the + // if the file is a .exe, start it directly; if it's anything else, ask the // shell to start it const auto fec = spawn::getFileExecutionContext(parent, targetInfo); @@ -497,7 +500,24 @@ ProcessRunner& ProcessRunner::setFromFile(QWidget* parent, const QFileInfo& targ case spawn::FileExecutionTypes::Other: // fall-through default: { + if (forceHook) { + auto assoc = env::getAssociation(targetInfo); + if (!assoc.executable.filePath().isEmpty()) { + setBinary(assoc.executable); + setArguments(assoc.formattedCommandLine); + setCurrentDirectory(assoc.executable.absoluteDir()); + + return *this; + } + + // if it fails, just use the regular shell open + } + m_shellOpen = targetInfo.absoluteFilePath(); + + // picked up by postRun() + m_sp.hooked = false; + break; } } @@ -722,6 +742,11 @@ ProcessRunner::Results ProcessRunner::postRun() { const bool mustWait = (m_waitFlags & ForceWait); + if (!m_sp.hooked && !mustWait) { + // the process wasn't hooked and there's no force wait, don't lock + return Running; + } + if (mustWait && m_lockReason == UILocker::NoReason) { // never lock the ui without an escape hatch for the user log::debug( |
