From b60f2aa786cf748e1839f4320604030863279032 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 24 Oct 2019 02:52:54 -0400 Subject: renamed startApplication() to runExecutableOrExecutableFile() --- src/main.cpp | 3 ++- src/organizercore.cpp | 40 +++++++++++++++++++--------------------- src/organizercore.h | 7 ++++++- src/organizerproxy.cpp | 12 ++++++++---- 4 files changed, 35 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 776c3775..49ecc084 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -653,7 +653,8 @@ int runApplication(MOApplication &application, SingleInstance &instance, arguments.removeFirst(); // remove binary name // pass the remaining parameters to the binary try { - organizer.startApplication(exeName, arguments, QString(), QString()); + organizer.runExecutableOrExecutableFile( + exeName, arguments, QString(), QString()); return 0; } catch (const std::exception &e) { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 6f36ee3e..6bf2c290 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1362,45 +1362,44 @@ HANDLE OrganizerCore::spawnAndWait( return handle; } -HANDLE OrganizerCore::startApplication(const QString &executable, - const QStringList &args, - const QString &cwd, - const QString &profile, - const QString &forcedCustomOverwrite, - bool ignoreCustomOverwrite) +HANDLE OrganizerCore::runExecutableOrExecutableFile( + const QString &executable, const QStringList &args, const QString &cwd, + const QString &profile, const QString &forcedCustomOverwrite, + bool ignoreCustomOverwrite) { - QFileInfo binary; - QString arguments = args.join(" "); - QString currentDirectory = cwd; QString profileName = profile; - if (profile.length() == 0) { + if (profile == "") { if (m_CurrentProfile != nullptr) { profileName = m_CurrentProfile->name(); } else { throw MyException(tr("No profile set")); } } + + QFileInfo binary; + QString arguments = args.join(" "); + QString currentDirectory = cwd; QString steamAppID; QString customOverwrite; QList forcedLibraries; + if (executable.contains('\\') || executable.contains('/')) { // file path binary = QFileInfo(executable); if (binary.isRelative()) { // relative path, should be relative to game directory - binary = QFileInfo( - managedGame()->gameDirectory().absoluteFilePath(executable)); + binary = managedGame()->gameDirectory().absoluteFilePath(executable); } - if (cwd.length() == 0) { + + if (currentDirectory == "") { currentDirectory = binary.absolutePath(); } + try { - const Executable &exe = m_ExecutablesList.getByBinary(binary); + const Executable& exe = m_ExecutablesList.getByBinary(binary); steamAppID = exe.steamAppID(); - customOverwrite - = m_CurrentProfile->setting("custom_overwrites", exe.title()) - .toString(); + customOverwrite = m_CurrentProfile->setting("custom_overwrites", exe.title()).toString(); if (m_CurrentProfile->forcedLibrariesEnabled(exe.title())) { forcedLibraries = m_CurrentProfile->determineForcedLibraries(exe.title()); } @@ -1412,9 +1411,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, try { const Executable &exe = m_ExecutablesList.get(executable); steamAppID = exe.steamAppID(); - customOverwrite - = m_CurrentProfile->setting("custom_overwrites", exe.title()) - .toString(); + customOverwrite = m_CurrentProfile->setting("custom_overwrites", exe.title()).toString(); if (m_CurrentProfile->forcedLibrariesEnabled(exe.title())) { forcedLibraries = m_CurrentProfile->determineForcedLibraries(exe.title()); } @@ -1422,7 +1419,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, arguments = exe.arguments(); } binary = exe.binaryInfo(); - if (cwd.length() == 0) { + if (currentDirectory == "") { currentDirectory = exe.workingDirectory(); } } catch (const std::runtime_error &) { @@ -1433,6 +1430,7 @@ HANDLE OrganizerCore::startApplication(const QString &executable, if (!forcedCustomOverwrite.isEmpty()) customOverwrite = forcedCustomOverwrite; + if (ignoreCustomOverwrite) customOverwrite.clear(); diff --git a/src/organizercore.h b/src/organizercore.h index ca87a05c..fa05a20f 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -174,6 +174,12 @@ public: bool runShortcut(const MOShortcut& shortcut); + HANDLE runExecutableOrExecutableFile( + const QString &executable, const QStringList &args, const QString &cwd, + const QString &profile, const QString &forcedCustomOverwrite = "", + bool ignoreCustomOverwrite = false); + + void loginSuccessfulUpdate(bool necessary); void loginFailedUpdate(const QString &message); @@ -227,7 +233,6 @@ public: DownloadManager *downloadManager(); PluginList *pluginList(); ModList *modList(); - HANDLE startApplication(const QString &executable, const QStringList &args, const QString &cwd, const QString &profile, const QString &forcedCustomOverwrite = "", bool ignoreCustomOverwrite = false); bool waitForApplication(HANDLE processHandle, LPDWORD exitCode = nullptr); HANDLE findAndOpenAUSVFSProcess(const std::vector& hiddenList, DWORD preferedParentPid); bool onModInstalled(const std::function &func); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index d6996b3a..2ea1761a 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -107,10 +107,14 @@ QString OrganizerProxy::pluginDataPath() const return m_Proxied->pluginDataPath(); } -HANDLE OrganizerProxy::startApplication(const QString &executable, const QStringList &args, const QString &cwd, - const QString &profile, const QString &forcedCustomOverwrite, bool ignoreCustomOverwrite) -{ - return m_Proxied->startApplication(executable, args, cwd, profile, forcedCustomOverwrite, ignoreCustomOverwrite); +HANDLE OrganizerProxy::startApplication( + const QString &executable, const QStringList &args, const QString &cwd, + const QString &profile, const QString &forcedCustomOverwrite, + bool ignoreCustomOverwrite) +{ + return m_Proxied->runExecutableOrExecutableFile( + executable, args, cwd, profile, + forcedCustomOverwrite, ignoreCustomOverwrite); } bool OrganizerProxy::waitForApplication(HANDLE handle, LPDWORD exitCode) const -- cgit v1.3.1