From acbc0a9b8f00289c5f3459a9e6d7eeffe057a35e Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 19 Jun 2025 00:19:14 +0100 Subject: [PATCH] Fix launching other binaries when the CWD is not the binary directory --- apps/opencs/model/doc/runner.cpp | 22 ++++++++++------------ components/process/processinvoker.cpp | 11 +++-------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/apps/opencs/model/doc/runner.cpp b/apps/opencs/model/doc/runner.cpp index d647d6b498..a9274ee5dc 100644 --- a/apps/opencs/model/doc/runner.cpp +++ b/apps/opencs/model/doc/runner.cpp @@ -2,11 +2,8 @@ #include -#if defined(Q_OS_MAC) #include #include -#endif - #include #include #include @@ -55,16 +52,17 @@ void CSMDoc::Runner::start(bool delayed) QString path = "openmw"; #ifdef Q_OS_WIN - path.append(QString(".exe")); -#elif defined(Q_OS_MAC) - QDir dir(QCoreApplication::applicationDirPath()); - dir.cdUp(); - dir.cdUp(); - dir.cdUp(); - path = dir.absoluteFilePath(path.prepend("OpenMW.app/Contents/MacOS/")); -#else - path.prepend(QString("./")); + path.append(QLatin1String(".exe")); #endif + QDir dir(QCoreApplication::applicationDirPath()); +#ifdef Q_OS_MAC + // the CS and engine are in separate .app directories + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); + path.prepend("OpenMW.app/Contents/MacOS/") +#endif + path = dir.absoluteFilePath(path); mStartup = new QTemporaryFile(this); mStartup->open(); diff --git a/components/process/processinvoker.cpp b/components/process/processinvoker.cpp index 9489076acb..04058c492d 100644 --- a/components/process/processinvoker.cpp +++ b/components/process/processinvoker.cpp @@ -1,13 +1,11 @@ #include "processinvoker.hpp" +#include #include #include #include #include -#if defined(Q_OS_MAC) -#include -#endif Process::ProcessInvoker::ProcessInvoker(QObject* parent) : QObject(parent) @@ -60,12 +58,9 @@ bool Process::ProcessInvoker::startProcess(const QString& name, const QStringLis QString path(name); #ifdef Q_OS_WIN path.append(QLatin1String(".exe")); -#elif defined(Q_OS_MAC) - QDir dir(QCoreApplication::applicationDirPath()); - path = dir.absoluteFilePath(name); -#else - path.prepend(QLatin1String("./")); #endif + QDir dir(QCoreApplication::applicationDirPath()); + path = dir.absoluteFilePath(path); QFileInfo info(path);