From a60d1ad6dc5784cef6fbf492a9962c2218da277c Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Wed, 13 Dec 2023 11:28:26 -0500 Subject: [PATCH] Fix config flag and update checker github repo url (#496) * fix config flag and update url * lint --- src/background-filter.cpp | 4 ++-- src/obs-utils/obs-config-utils.cpp | 31 +++++++++++++-------------- src/obs-utils/obs-config-utils.h | 2 +- src/update-checker/UpdateDialog.cpp | 2 +- src/update-checker/github-utils.cpp | 2 +- src/update-checker/update-checker.cpp | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/background-filter.cpp b/src/background-filter.cpp index bdc81546..89519575 100644 --- a/src/background-filter.cpp +++ b/src/background-filter.cpp @@ -39,7 +39,7 @@ struct background_removal_filter : public filter_data { int maskEveryXFrames = 1; int maskEveryXFramesCount = 0; int64_t blurBackground = 0; - bool enableFocalBlur = true; + bool enableFocalBlur = false; float blurFocusPoint = 0.1f; float blurFocusDepth = 0.1f; @@ -199,7 +199,7 @@ void background_filter_defaults(obs_data_t *settings) obs_data_set_default_int(settings, "mask_every_x_frames", 1); obs_data_set_default_int(settings, "blur_background", 0); obs_data_set_default_int(settings, "numThreads", 1); - obs_data_set_default_bool(settings, "enable_focal_blur", true); + obs_data_set_default_bool(settings, "enable_focal_blur", false); obs_data_set_default_double(settings, "blur_focus_point", 0.1); obs_data_set_default_double(settings, "blur_focus_depth", 0.0); } diff --git a/src/obs-utils/obs-config-utils.cpp b/src/obs-utils/obs-config-utils.cpp index 91fdce6d..291dbde9 100644 --- a/src/obs-utils/obs-config-utils.cpp +++ b/src/obs-utils/obs-config-utils.cpp @@ -29,18 +29,28 @@ void create_config_folder() } } -int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue) +int getConfig(config_t **config) { create_config_folder(); // ensure the config folder exists // Get the config file char *config_file_path = obs_module_config_path("config.ini"); - config_t *config; - int ret = config_open(&config, config_file_path, CONFIG_OPEN_EXISTING); + int ret = config_open(config, config_file_path, CONFIG_OPEN_EXISTING); if (ret != CONFIG_SUCCESS) { obs_log(LOG_INFO, "Failed to open config file %s", config_file_path); + return OBS_BGREMOVAL_CONFIG_FAIL; + } + + return OBS_BGREMOVAL_CONFIG_SUCCESS; +} + +int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue) +{ + // Get the config file + config_t *config; + if (getConfig(&config) != OBS_BGREMOVAL_CONFIG_SUCCESS) { *returnValue = defaultValue; return OBS_BGREMOVAL_CONFIG_FAIL; } @@ -48,23 +58,14 @@ int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue) *returnValue = config_get_bool(config, "config", name); config_close(config); - bfree(config_file_path); - return OBS_BGREMOVAL_CONFIG_SUCCESS; } -int setFlagFromConfig(const char *name, const bool value) +int setFlagInConfig(const char *name, const bool value) { - create_config_folder(); // ensure the config folder exists - // Get the config file - char *config_file_path = obs_module_config_path("config.ini"); - config_t *config; - int ret = config_open(&config, config_file_path, CONFIG_OPEN_ALWAYS); - if (ret != CONFIG_SUCCESS) { - obs_log(LOG_INFO, "Failed to open config file %s", - config_file_path); + if (getConfig(&config) != OBS_BGREMOVAL_CONFIG_SUCCESS) { return OBS_BGREMOVAL_CONFIG_FAIL; } @@ -72,7 +73,5 @@ int setFlagFromConfig(const char *name, const bool value) config_save(config); config_close(config); - bfree(config_file_path); - return OBS_BGREMOVAL_CONFIG_SUCCESS; } diff --git a/src/obs-utils/obs-config-utils.h b/src/obs-utils/obs-config-utils.h index 00166611..cf79b31a 100644 --- a/src/obs-utils/obs-config-utils.h +++ b/src/obs-utils/obs-config-utils.h @@ -25,6 +25,6 @@ int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue); * @return OBS_BGREMOVAL_CONFIG_SUCCESS if the config item was found, * OBS_BGREMOVAL_CONFIG_FAIL otherwise. */ -int setFlagFromConfig(const char *name, const bool value); +int setFlagInConfig(const char *name, const bool value); #endif /* OBS_CONFIG_UTILS_H */ diff --git a/src/update-checker/UpdateDialog.cpp b/src/update-checker/UpdateDialog.cpp index 1b459862..fffc4ce8 100644 --- a/src/update-checker/UpdateDialog.cpp +++ b/src/update-checker/UpdateDialog.cpp @@ -54,7 +54,7 @@ UpdateDialog::UpdateDialog( QCheckBox *disableCheckbox = new QCheckBox("Disable update checks"); layout->addWidget(disableCheckbox); connect(disableCheckbox, &QCheckBox::stateChanged, this, [](int state) { - setFlagFromConfig("check_for_updates", state == Qt::Unchecked); + setFlagInConfig("check_for_updates", state == Qt::Unchecked); }); // Add a button to close the dialog diff --git a/src/update-checker/github-utils.cpp b/src/update-checker/github-utils.cpp index 18e26e6b..5e0e6616 100644 --- a/src/update-checker/github-utils.cpp +++ b/src/update-checker/github-utils.cpp @@ -8,7 +8,7 @@ #include "plugin-support.h" static const std::string GITHUB_LATEST_RELEASE_URL = - "https://api.github.com/repos/obs-ai/obs-backgroundremoval/releases/latest"; + "https://api.github.com/repos/occ-ai/obs-backgroundremoval/releases/latest"; void github_utils_get_release_information( std::function callback) diff --git a/src/update-checker/update-checker.cpp b/src/update-checker/update-checker.cpp index f8568594..363008b7 100644 --- a/src/update-checker/update-checker.cpp +++ b/src/update-checker/update-checker.cpp @@ -22,7 +22,7 @@ void check_update(void) // Failed to get the config value, assume it's enabled shouldCheckForUpdates = true; // store the default value - setFlagFromConfig("check_for_updates", shouldCheckForUpdates); + setFlagInConfig("check_for_updates", shouldCheckForUpdates); } if (!shouldCheckForUpdates) {