mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-11-15 03:36:53 -06:00
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.
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
#include <obs-module.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#define ADVSS_SETENV(k, v) _putenv_s(k, v)
|
||||
#define ADVSS_UNSETENV(k) _putenv_s(k, "")
|
||||
#define ADVSS_GETPID() _getpid()
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user