From 80c0bc7bc73c21293e950d7ef2482887ec5892d6 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Sat, 31 Oct 2026 10:39:28 +0100 Subject: [PATCH] Fix plugin not loading after OBS auto-update Env var was unset only after updater already inherited its value. So now we also compare the value of the env var which now stores the PID. --- module/advanced-scene-switcher-module.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/advanced-scene-switcher-module.c b/module/advanced-scene-switcher-module.c index 038766bd..5ba4c426 100644 --- a/module/advanced-scene-switcher-module.c +++ b/module/advanced-scene-switcher-module.c @@ -1,13 +1,19 @@ #include #include +#include #include +#include #ifdef _WIN32 +#include #define ADVSS_SETENV(k, v) _putenv_s(k, v) #define ADVSS_UNSETENV(k) _putenv_s(k, "") +#define ADVSS_GETPID() _getpid() #else +#include #define ADVSS_SETENV(k, v) setenv(k, v, 1) #define ADVSS_UNSETENV(k) unsetenv(k) +#define ADVSS_GETPID() getpid() #endif #define ADVSS_INSTANCE_ENV "ADVSS_INSTANCE_LOADED" @@ -28,12 +34,16 @@ void obs_module_post_load(void) bool obs_module_load(void) { - if (getenv(ADVSS_INSTANCE_ENV)) { + char pid[32]; + snprintf(pid, sizeof(pid), "%d", (int)ADVSS_GETPID()); + + const char *loadedPid = getenv(ADVSS_INSTANCE_ENV); + if (loadedPid && strcmp(loadedPid, pid) == 0) { blog(LOG_WARNING, "[adv-ss] Another instance is already loaded - skipping."); return false; } - ADVSS_SETENV(ADVSS_INSTANCE_ENV, "1"); + ADVSS_SETENV(ADVSS_INSTANCE_ENV, pid); obs_frontend_push_ui_translation(obs_module_get_string); InitSceneSwitcher(obs_current_module(), obs_module_text); return true;