From c7101be7d8a077eba563a6fd6f15ec8169eeca51 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 25 Jun 2016 11:47:15 +0100 Subject: Some refactoring of the spawn code and to make waitForApplication get the right error code (usually) A note: It is possible for the executed program to completely exit before MO attempts to get hold of the pid from the job handle, in which case strangeness will happen (this has always been an issue) --- src/organizercore.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/organizercore.h') diff --git a/src/organizercore.h b/src/organizercore.h index b50b3e9f..120e83fa 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -21,21 +21,28 @@ class ModListSortProxy; class PluginListSortProxy; class Profile; -namespace MOBase { template class GuessedValue; } +namespace MOBase { + template class GuessedValue; + class IModInterface; +} namespace MOShared { class DirectoryEntry; } #include +#include #include #include #include #include #include #include +#include class QNetworkReply; class QUrl; class QWidget; +#include //for HANDLE, LPDWORD + #include #include @@ -222,11 +229,7 @@ private: bool testForSteam(); - /* - * std::vector> fileMapping(const QString &dataPath, - const MOShared::DirectoryEntry *base, - const MOShared::DirectoryEntry *directoryEntry); -*/ + bool waitForProcessCompletion(HANDLE handle, LPDWORD exitCode); private slots: -- cgit v1.3.1 From 607b2a10aa4eab4c8b0534be20696ebe55151b9a Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 26 Jun 2016 20:27:13 +0100 Subject: Restore commented out code --- src/organizercore.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- src/organizercore.h | 6 ++++++ 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src/organizercore.h') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index f202d447..196ef6bf 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -918,7 +918,7 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID); if (processHandle != INVALID_HANDLE_VALUE) { - if (closeAfterStart && m_UserInterface != nullptr) { + if (closeAfterStart && (m_UserInterface != nullptr)) { m_UserInterface->closeWindow(); } else { @@ -1592,3 +1592,43 @@ void OrganizerCore::prepareStart() { storeSettings(); } +/* +std::vector> OrganizerCore::fileMapping() +{ + return fileMapping(managedGame()->dataDirectory().absolutePath(), + directoryStructure(), + directoryStructure()); +} + + +std::vector> OrganizerCore::fileMapping( + const QString &dataPath, + const DirectoryEntry *base, + const DirectoryEntry *directoryEntry) +{ + std::vector> result; + + for (FileEntry::Ptr current : directoryEntry->getFiles()) { + bool isArchive = false; + int origin = current->getOrigin(isArchive); + if (isArchive || (origin == 0)) { + continue; + } + + QString fileName = ToQString(current->getRelativePath()); + QString source = ToQString(base->getOriginByID(origin).getPath()) + fileName; + QString target = QDir::toNativeSeparators(dataPath) + fileName; + result.push_back(std::make_pair(source, target)); + } + + // recurse into subdirectories + std::vector::const_iterator current, end; + directoryEntry->getSubDirectories(current, end); + for (; current != end; ++current) { + std::vector> subRes = fileMapping(dataPath, base, *current); + result.insert(result.end(), subRes.begin(), subRes.end()); + } + return result; +} + +*/ diff --git a/src/organizercore.h b/src/organizercore.h index 120e83fa..28fc14ca 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -229,6 +229,12 @@ private: bool testForSteam(); + /* + * std::vector> fileMapping(const QString &dataPath, + const MOShared::DirectoryEntry *base, + const MOShared::DirectoryEntry *directoryEntry); +*/ + bool waitForProcessCompletion(HANDLE handle, LPDWORD exitCode); private slots: -- cgit v1.3.1