From 55b23a26d24cfd66e114bbf34752d72740314da5 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Fri, 29 Apr 2022 20:51:42 +0200 Subject: [PATCH] UI: Fix configuration path handling for Linux portable builds Original code uses simple `ifdef` pattern as well using the preprocessor definition in a conditional check. With the rework, the definition was set to an empty string (if the build flag is not enabled), which leads to it being evaluated as "true" all the time. This change uses simpler definition check and fences off code relying on the flag being enabled. --- UI/obs-app.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index f24cb656c..16f6adf35 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -2347,13 +2347,10 @@ static void load_debug_privilege(void) #define CONFIG_PATH BASE_PATH "/config" -#ifndef LINUX_PORTABLE -#define LINUX_PORTABLE 0 -#endif - int GetConfigPath(char *path, size_t size, const char *name) { - if (LINUX_PORTABLE && portable_mode) { +#ifdef LINUX_PORTABLE + if (portable_mode) { if (name && *name) { return snprintf(path, size, CONFIG_PATH "/%s", name); } else { @@ -2362,11 +2359,15 @@ int GetConfigPath(char *path, size_t size, const char *name) } else { return os_get_config_path(path, size, name); } +#else + return os_get_config_path(path, size, name); +#endif } char *GetConfigPathPtr(const char *name) { - if (LINUX_PORTABLE && portable_mode) { +#ifdef LINUX_PORTABLE + if (portable_mode) { char path[512]; if (snprintf(path, sizeof(path), CONFIG_PATH "/%s", name) > 0) { @@ -2377,6 +2378,9 @@ char *GetConfigPathPtr(const char *name) } else { return os_get_config_path_ptr(name); } +#else + return os_get_config_path_ptr(name); +#endif } int GetProgramDataPath(char *path, size_t size, const char *name)