diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2021-02-12 03:22:52 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2021-02-12 03:22:52 -0500 |
| commit | 48274f33579076711c0475e84c7adf68c52df733 (patch) | |
| tree | 51e564e682430179920b7ab937a5f66c27e0645f /src/processrunner.cpp | |
| parent | 7d36bc20d0a6c327079141149a7f138c0f7726ac (diff) | |
- renamed instance::name() to displayName() to reduce confusion with portable instances
- better errors when running incorrect shortcuts
- fixed shortcuts being created with moshortcut://Portable:exe instead of an empty instance name for portable instances
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; } |
