]> granicus.if.org Git - handbrake/commitdiff
presets: fix importing file with "Official" presets
authorJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 27 Jun 2018 18:06:02 +0000 (11:06 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 27 Jun 2018 18:06:02 +0000 (11:06 -0700)
Convert any presets with "Type" official to custom before importing.
This can happen if someone decides to try to import a full user presets
file from a previous install of HandBrake.

libhb/preset.c

index 4a581e01708ee878deb538d30adc4d5ae6c43804..6a7f0d1222c8218495a643b1e0645e120ff93ded 100644 (file)
@@ -174,6 +174,12 @@ static int do_preset_clean(hb_value_t *preset, preset_do_context_t *do_ctx)
     return PRESET_DO_NEXT;
 }
 
+static int do_make_custom(hb_value_t *preset, preset_do_context_t *ctx)
+{
+    hb_dict_set_int(preset, "Type", HB_PRESET_TYPE_CUSTOM);
+    return PRESET_DO_NEXT;
+}
+
 static int do_delete_builtin(hb_value_t *preset, preset_do_context_t *ctx)
 {
     if (hb_value_get_int(hb_dict_get(preset, "Type")) == HB_PRESET_TYPE_OFFICIAL)
@@ -3655,6 +3661,11 @@ int hb_presets_add_file(const char *filename)
     if (preset == NULL)
         return -1;
 
+    preset_do_context_t ctx;
+
+    ctx.path.depth = 1;
+    presets_do(do_make_custom, preset, &ctx);
+
     int result = hb_presets_add(preset);
     hb_value_free(&preset);