Merge pull request #46 from Snegovoy98/fix_macos_apppath
All checks were successful
buildbot/DocsGenerator Build finished.
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.

Fix for MacOS application path params
This commit is contained in:
Andrei Yankovich 2024-08-02 15:34:10 +03:00 committed by GitHub
commit 88414ce06f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,8 +11,13 @@
#include <QFileInfo>
#include <QDateTime>
#include <QCoreApplication>
#include "qaglobalutils.h"
#include <QtLogging>
#ifdef Q_OS_DARWIN
#include <mach-o/dyld.h>
#endif
#ifdef Q_OS_WIN
#include "windows.h"
#else
@ -229,7 +234,15 @@ bool Params::parseParams(const QStringList &paramsArray, const OptionsDataList &
#endif
#ifdef Q_OS_DARWIN
appPath = QCoreApplication::applicationDirPath();
uint32_t size = 0;
_NSGetExecutablePath(nullptr, &size); // request to buffer size
std::vector<char> buffer(size);
if (_NSGetExecutablePath(buffer.data(), &size) == 0) {
appPath = QString::fromUtf8(buffer.data());
} else {
appPath = QString();
}
appName = QCoreApplication::applicationName();
#endif