From 503fed19a77d7aa50265ea7b6e03055512093828 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Wed, 17 Jan 2018 10:36:34 -0800 Subject: [PATCH] Trying to fix mac resource loading --- libraries/shared/src/PathUtils.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/PathUtils.cpp b/libraries/shared/src/PathUtils.cpp index f98cee50a1..850ffa60fd 100644 --- a/libraries/shared/src/PathUtils.cpp +++ b/libraries/shared/src/PathUtils.cpp @@ -25,6 +25,11 @@ #include #include +#if defined(Q_OS_OSX) +#include +#endif + + #include "shared/GlobalAppProperties.h" #include "SharedUtil.h" @@ -33,9 +38,13 @@ QString TEMP_DIR_FORMAT { "%1-%2-%3" }; #if !defined(Q_OS_ANDROID) && defined(DEV_BUILD) +#if defined(Q_OS_OSX) +static bool USE_SOURCE_TREE_RESOURCES = true; +#else static const QString USE_SOURCE_TREE_RESOURCES_FLAG("HIFI_USE_SOURCE_TREE_RESOURCES"); static bool USE_SOURCE_TREE_RESOURCES = QProcessEnvironment::systemEnvironment().contains(USE_SOURCE_TREE_RESOURCES_FLAG); #endif +#endif #ifdef DEV_BUILD const QString& PathUtils::projectRootPath() { @@ -57,7 +66,12 @@ const QString& PathUtils::resourcesPath() { #if defined(Q_OS_OSX) // FIXME fix the OSX installer to install the resources.rcc instead of the // individual resource files - staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; + // FIXME the first call to fetch the resources location seems to return + // nothing for QCoreApplication::applicationDirPath() + char buffer[8192]; + uint32_t bufferSize = sizeof(buffer); + _NSGetExecutablePath(buffer, &bufferSize); + staticResourcePath = QFileInfo(buffer).dir().absoluteFilePath("../Resources") + "/"; #else staticResourcePath = ":/"; #endif