diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2021-02-12 18:09:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-12 18:09:15 +0100 |
| commit | 607fafa364a1f3935b289172e3291eafed13014b (patch) | |
| tree | a4695ea1507a8c25fada52617ff4e2b7d58e9ae3 /src/processrunner.cpp | |
| parent | 7dc28b10d9ed4cd4af15eeaca89b50996d6fd27d (diff) | |
| parent | 48274f33579076711c0475e84c7adf68c52df733 (diff) | |
Merge pull request #1408 from isanae/portable-shortcuts
Fixes for portable shortcuts
Diffstat (limited to 'src/processrunner.cpp')
| -rw-r--r-- | src/processrunner.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/processrunner.cpp b/src/processrunner.cpp index c932ce44..4d83d0c8 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -4,6 +4,7 @@ #include "iuserinterface.h" #include "envmodule.h" #include "env.h" +#include <report.h> #include <iplugingame.h> #include <log.h> @@ -607,16 +608,30 @@ ProcessRunner& ProcessRunner::setFromShortcut(const MOShortcut& shortcut) if (currentInstance) { - if (shortcut.hasInstance() && shortcut.instance() != currentInstance->name()) { - throw std::runtime_error( - QString("Refusing to run executable from different instance %1:%2") - .arg(shortcut.instance(),shortcut.executable()) - .toLocal8Bit().constData()); + if (shortcut.hasInstance() && !shortcut.isForInstance(*currentInstance)) { + MOBase::reportError(QObject::tr( + "This shortcut is for instance '%1' but Mod Organizer is currently " + "running for '%2'. Exit Mod Organizer before running the shortcut or " + "change the active instance.") + .arg(shortcut.instanceDisplayName()) + .arg(currentInstance->displayName())); + + throw std::exception(); } } - const Executable& exe = m_core.executablesList()->get(shortcut.executable()); - setFromExecutable(exe); + const auto* exes = m_core.executablesList(); + const auto exe = exes->find(shortcut.executableName()); + + if (exe != exes->end()) { + setFromExecutable(*exe); + } else { + MOBase::reportError(QObject::tr( + "Executable '%1' does not exist in instance '%2'.") + .arg(shortcut.executableName()).arg(currentInstance->displayName())); + + throw std::exception(); + } return *this; } |
