From cb1c9f5e83e98039d38f548c80d4b95442163cf2 Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Tue, 19 Dec 2017 00:44:18 +0200 Subject: Tie moshortcuts to a specific instance --- src/main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 4cf47a3c..3d315f1d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,6 +45,7 @@ along with Mod Organizer. If not, see . #include "tutorialmanager.h" #include "nxmaccessmanager.h" #include "instancemanager.h" +#include "moshortcut.h" #include #include @@ -450,9 +451,9 @@ int runApplication(MOApplication &application, SingleInstance &instance, // if we have a command line parameter, it is either a nxm link or // a binary to start if (arguments.size() > 1) { - if (OrganizerCore::isMoShortcut(arguments.at(1))) { + if (MOShortcut shortcut{ arguments.at(1) }) { try { - organizer.runShortcut(OrganizerCore::moShortcutName(arguments.at(1))); + organizer.runShortcut(shortcut); return 0; } catch (const std::exception &e) { reportError( @@ -552,10 +553,12 @@ int main(int argc, char *argv[]) forcePrimary = true; } + MOShortcut moshortcut{ arguments.size() > 1 ? arguments.at(1) : "" }; + SingleInstance instance(forcePrimary); if (!instance.primaryInstance()) { - if ((arguments.size() == 2) - && (OrganizerCore::isMoShortcut(arguments.at(1)) || OrganizerCore::isNxmLink(arguments.at(1)))) + if (moshortcut || + arguments.size() > 1 && OrganizerCore::isNxmLink(arguments.at(1))) { qDebug("not primary instance, sending shortcut/download message"); instance.sendMessage(arguments.at(1)); @@ -572,7 +575,10 @@ int main(int argc, char *argv[]) QString dataPath; try { - dataPath = InstanceManager::instance().determineDataPath(); + InstanceManager& instanceManager = InstanceManager::instance(); + if (moshortcut && moshortcut.hasInstance()) + instanceManager.overrideInstance(moshortcut.instance()); + dataPath = instanceManager.determineDataPath(); } catch (const std::exception &e) { if (strcmp(e.what(),"Canceled")) QMessageBox::critical(nullptr, QObject::tr("Failed to set up instance"), e.what()); -- cgit v1.3.1