From a1cc4539961b608ffccebb34b83fc9a6a156f22a Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Mon, 22 Jul 2019 02:37:40 +0200 Subject: [PATCH] libobs: Fix apply_settings & remove_by_name for groups 'obs_properties_apply_settings' and 'obs_properties_remove_by_name' would incorrectly ignore property groups and not call the callbacks or remove the property, resulting in quite glitchy UI. This fix works by splitting the internal logic of ...apply_settings into an extra function to call, while keeping the API the same. The change to ...remove_by_name is to simply recursively going into the group content with the same function call. --- libobs/obs-properties.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/libobs/obs-properties.c b/libobs/obs-properties.c index 4deb441b4..b52c6c46b 100644 --- a/libobs/obs-properties.c +++ b/libobs/obs-properties.c @@ -336,27 +336,44 @@ void obs_properties_remove_by_name(obs_properties_t *props, const char *name) break; } + if (cur->type == OBS_PROPERTY_GROUP) { + obs_properties_remove_by_name( + obs_property_group_content(cur), name); + } + prev = cur; cur = cur->next; } } +void obs_properties_apply_settings_internal(obs_properties_t *props, + obs_data_t *settings, + obs_properties_t *realprops) +{ + struct obs_property *p; + + p = props->first_property; + while (p) { + if (p->type == OBS_PROPERTY_GROUP) { + obs_properties_apply_settings_internal( + obs_property_group_content(p), settings, + realprops); + } + if (p->modified) + p->modified(realprops, p, settings); + else if (p->modified2) + p->modified2(p->priv, realprops, p, settings); + p = p->next; + } +} + void obs_properties_apply_settings(obs_properties_t *props, obs_data_t *settings) { - struct obs_property *p; - if (!props) return; - p = props->first_property; - while (p) { - if (p->modified) - p->modified(props, p, settings); - else if (p->modified2) - p->modified2(p->priv, props, p, settings); - p = p->next; - } + obs_properties_apply_settings_internal(props, settings, props); } /* ------------------------------------------------------------------------- */