diff options
| author | Eran Mizrahi <erasmux@gmail.com> | 2017-12-19 00:44:18 +0200 |
|---|---|---|
| committer | Eran Mizrahi <erasmux@gmail.com> | 2017-12-19 15:44:27 +0200 |
| commit | cb1c9f5e83e98039d38f548c80d4b95442163cf2 (patch) | |
| tree | eba934e34a24a9484ab076065f9e98aefca16425 /src/main.cpp | |
| parent | 7dad8bcb282ac385267087961b29af608f81593d (diff) | |
Tie moshortcuts to a specific instance
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
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 <http://www.gnu.org/licenses/>. #include "tutorialmanager.h"
#include "nxmaccessmanager.h"
#include "instancemanager.h"
+#include "moshortcut.h"
#include <eh.h>
#include <windows_error.h>
@@ -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());
|
