From 48274f33579076711c0475e84c7adf68c52df733 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 12 Feb 2021 03:22:52 -0500 Subject: - 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 --- src/processrunner.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/processrunner.cpp') 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 #include #include @@ -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; } -- cgit v1.3.1