]> granicus.if.org Git - handbrake/commitdiff
LinGui: clean settings better before writing to presets file
authorjstebbins <jstebbins.hb@gmail.com>
Sat, 7 Mar 2015 16:48:41 +0000 (16:48 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sat, 7 Mar 2015 16:48:41 +0000 (16:48 +0000)
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

gtk/src/presets.c

index acaf31dbb896b9ffab6a96b58fae337c8c2ecd82..520efbbd1326e3eea31a374667fbee623cac7d2b 100644 (file)
@@ -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);
 }