summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-10-18 22:42:47 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-11-06 07:42:56 -0500
commit74631ae88e36f7ccc1ea80c5a56d686637c325c6 (patch)
tree8f822be8ababda89167204a4f8ac7932b8c0ba7e /src
parentd91580cc2669e2ab018c2aaab472cd763e5441d8 (diff)
merged spawnBinaryDirect() and spawnBinaryProcess()
Diffstat (limited to 'src')
-rw-r--r--src/organizercore.cpp98
-rw-r--r--src/organizercore.h23
2 files changed, 56 insertions, 65 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 3c986004..3bb6af70 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1208,15 +1208,17 @@ bool OrganizerCore::previewFile(
return true;
}
-void OrganizerCore::spawnBinary(const QFileInfo &binary,
- const QString &arguments,
- const QDir &currentDirectory,
- const QString &steamAppID,
- const QString &customOverwrite,
- const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries)
+void OrganizerCore::spawnBinary(
+ const QFileInfo &binary, const QString &arguments,
+ const QDir &currentDirectory, const QString &steamAppID,
+ const QString &customOverwrite,
+ const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries)
{
DWORD processExitCode = 0;
- HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID, customOverwrite, forcedLibraries, &processExitCode);
+ HANDLE processHandle = spawnBinaryDirect(
+ binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID,
+ customOverwrite, forcedLibraries, &processExitCode);
+
if (processHandle != INVALID_HANDLE_VALUE) {
refreshDirectoryStructure();
// need to remove our stored load order because it may be outdated if a foreign tool changed the
@@ -1235,50 +1237,12 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary,
}
}
-HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary,
- const QString &arguments,
- const QString &profileName,
- const QDir &currentDirectory,
- const QString &steamAppID,
- const QString &customOverwrite,
- const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries,
- LPDWORD exitCode)
-{
- HANDLE processHandle = spawnBinaryProcess(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite, forcedLibraries);
- if (Settings::instance().interface().lockGUI() && processHandle != INVALID_HANDLE_VALUE) {
- std::unique_ptr<LockedDialog> dlg;
- ILockedWaitingForProcess* uilock = nullptr;
-
- if (m_MainWindow != nullptr) {
- uilock = m_MainWindow->lock();
- }
- else {
- // i.e. when running command line shortcuts there is no user interface
- dlg.reset(new LockedDialog);
- dlg->show();
- dlg->setEnabled(true);
- uilock = dlg.get();
- }
-
- ON_BLOCK_EXIT([&]() {
- if (m_MainWindow != nullptr) {
- m_MainWindow->unlock();
- } });
-
- DWORD ignoreExitCode;
- waitForProcessCompletion(processHandle, exitCode ? exitCode : &ignoreExitCode, uilock);
- cycleDiagnostics();
- }
-
- return processHandle;
-}
-
-
-HANDLE OrganizerCore::spawnBinaryProcess(
+HANDLE OrganizerCore::spawnBinaryDirect(
const QFileInfo &binary, const QString &arguments, const QString &profileName,
const QDir &currentDirectory, const QString &steamAppID,
const QString &customOverwrite,
- const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries)
+ const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries,
+ LPDWORD exitCode)
{
spawn::SpawnParameters sp;
sp.binary = binary;
@@ -1317,10 +1281,44 @@ HANDLE OrganizerCore::spawnBinaryProcess(
return INVALID_HANDLE_VALUE;
}
- auto process = spawn::Spawner().spawn(m_MainWindow, m_GamePlugin, sp, m_Settings);
- return process.releaseHandle();
+ HANDLE handle = spawn::Spawner()
+ .spawn(m_MainWindow, m_GamePlugin, sp, m_Settings)
+ .releaseHandle();
+
+ if (handle == INVALID_HANDLE_VALUE) {
+ // failed
+ return INVALID_HANDLE_VALUE;
+ }
+
+ if (Settings::instance().interface().lockGUI()) {
+ std::unique_ptr<LockedDialog> dlg;
+ ILockedWaitingForProcess* uilock = nullptr;
+
+ if (m_MainWindow != nullptr) {
+ uilock = m_MainWindow->lock();
+ }
+ else {
+ // i.e. when running command line shortcuts there is no user interface
+ dlg.reset(new LockedDialog);
+ dlg->show();
+ dlg->setEnabled(true);
+ uilock = dlg.get();
+ }
+
+ ON_BLOCK_EXIT([&]() {
+ if (m_MainWindow != nullptr) {
+ m_MainWindow->unlock();
+ } });
+
+ DWORD ignoreExitCode;
+ waitForProcessCompletion(handle, exitCode ? exitCode : &ignoreExitCode, uilock);
+ cycleDiagnostics();
+ }
+
+ return handle;
}
+
HANDLE OrganizerCore::runShortcut(const MOShortcut& shortcut)
{
if (shortcut.hasInstance() && shortcut.instance() != InstanceManager::instance().currentInstance())
diff --git a/src/organizercore.h b/src/organizercore.h
index 04c96ba6..4a8f90d1 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -168,21 +168,6 @@ public:
const QString &customOverwrite = "",
const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries = QList<MOBase::ExecutableForcedLoadSetting>());
- HANDLE spawnBinaryDirect(const QFileInfo &binary, const QString &arguments,
- const QString &profileName,
- const QDir &currentDirectory,
- const QString &steamAppID,
- const QString &customOverwrite,
- const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries = QList<MOBase::ExecutableForcedLoadSetting>(),
- LPDWORD exitCode = nullptr);
-
- HANDLE spawnBinaryProcess(const QFileInfo &binary, const QString &arguments,
- const QString &profileName,
- const QDir &currentDirectory,
- const QString &steamAppID,
- const QString &customOverwrite,
- const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries = QList<MOBase::ExecutableForcedLoadSetting>());
-
void loginSuccessfulUpdate(bool necessary);
void loginFailedUpdate(const QString &message);
@@ -315,6 +300,14 @@ private:
const MOShared::DirectoryEntry *directoryEntry,
int createDestination);
+ HANDLE spawnBinaryDirect(const QFileInfo &binary, const QString &arguments,
+ const QString &profileName,
+ const QDir &currentDirectory,
+ const QString &steamAppID,
+ const QString &customOverwrite,
+ const QList<MOBase::ExecutableForcedLoadSetting> &forcedLibraries = QList<MOBase::ExecutableForcedLoadSetting>(),
+ LPDWORD exitCode = nullptr);
+
bool waitForProcessCompletion(HANDLE handle, LPDWORD exitCode, ILockedWaitingForProcess* uilock);
private slots: