From 149c38d54d2a841af929b432b83804fafdc1e588 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Mon, 15 Apr 2019 04:11:06 -0500 Subject: Add protection against non-existent working directory for executables --- src/executableslist.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index c7786c20..4b2e380b 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -57,7 +57,7 @@ void ExecutablesList::init(IPluginGame const *game) } ExecutableInfo explorerpp = ExecutableInfo("Explore Virtual Folder", QFileInfo(QCoreApplication::applicationDirPath() + "/explorer++/Explorer++.exe" )) .withArgument(QString("\"%1\"").arg(QDir::toNativeSeparators(game->dataDirectory().absolutePath()))); - + if (explorerpp.isValid()) { addExecutableInternal(explorerpp.title(), explorerpp.binary().absoluteFilePath(), @@ -65,7 +65,7 @@ void ExecutablesList::init(IPluginGame const *game) explorerpp.workingDirectory().absolutePath(), explorerpp.steamAppID()); } - + } void ExecutablesList::getExecutables(std::vector::iterator &begin, std::vector::iterator &end) @@ -152,6 +152,7 @@ void ExecutablesList::updateExecutable(const QString &title, Executable::Flags flags) { QFileInfo file(executableName); + QDir dir(workingDirectory); auto existingExe = findExe(title); flags &= mask; @@ -165,8 +166,11 @@ void ExecutablesList::updateExecutable(const QString &title, // don't overwrite a valid binary with an invalid one existingExe->m_BinaryInfo = file; } + if (dir.exists()) { + // don't overwrite a valid working directory with an invalid one + existingExe->m_WorkingDirectory = workingDirectory; + } existingExe->m_Arguments = arguments; - existingExe->m_WorkingDirectory = workingDirectory; existingExe->m_SteamAppID = steamAppID; } } else { -- cgit v1.3.1