Skip to content

Commit

Permalink
Fix config flag and update checker github repo url (#496)
Browse files Browse the repository at this point in the history
* fix config flag and update url

* lint
  • Loading branch information
royshil authored Dec 13, 2023
1 parent 9a1d13c commit a60d1ad
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/background-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
31 changes: 15 additions & 16 deletions src/obs-utils/obs-config-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,49 @@ 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;
}

*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;
}

config_set_bool(config, "config", name, value);
config_save(config);
config_close(config);

bfree(config_file_path);

return OBS_BGREMOVAL_CONFIG_SUCCESS;
}
2 changes: 1 addition & 1 deletion src/obs-utils/obs-config-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion src/update-checker/UpdateDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/update-checker/github-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(github_utils_release_information)> callback)
Expand Down
2 changes: 1 addition & 1 deletion src/update-checker/update-checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a60d1ad

Please # to comment.