From: jstebbins Date: Sat, 7 Mar 2015 16:48:41 +0000 (+0000) Subject: LinGui: clean settings better before writing to presets file X-Git-Tag: 1.0.0~1364 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c99a5be961b64a83a7a28ce99addd20c7ec1f96;p=handbrake LinGui: clean settings better before writing to presets file Some internal settings were getting written out to the presets file. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6972 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/gtk/src/presets.c b/gtk/src/presets.c index acaf31dbb..520efbbd1 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -57,17 +57,44 @@ dict_clean(GhbValue *dict, GhbValue *template) GhbValue *tmp = ghb_value_dup(dict); GhbDictIter iter; const gchar *key; - GhbValue *value; + GhbValue *val; GhbValue *template_val; ghb_dict_iter_init(tmp, &iter); - while (ghb_dict_iter_next(tmp, &iter, &key, &value)) + while (ghb_dict_iter_next(tmp, &iter, &key, &val)) { template_val = ghb_dict_lookup(template, key); if (template_val == NULL) { ghb_dict_remove(dict, key); } + if (ghb_value_type(val) == GHB_DICT && + ghb_value_type(template_val) == GHB_DICT) + { + val = ghb_dict_lookup(dict, key); + dict_clean(val, template_val); + } + if (ghb_value_type(val) == GHB_ARRAY && + ghb_value_type(template_val) == GHB_ARRAY && + ghb_array_len(template_val) > 0) + { + template_val = ghb_array_get_nth(template_val, 0); + if (ghb_value_type(template_val) == GHB_DICT) + { + val = ghb_dict_lookup(dict, key); + int count = ghb_array_len(val); + int ii; + for (ii = 0; ii < count; ii++) + { + GhbValue *array_val; + array_val = ghb_array_get_nth(val, ii); + if (ghb_value_type(array_val) == GHB_DICT) + { + dict_clean(array_val, template_val); + } + } + } + } } ghb_value_free(tmp); }