From 12c76e91df09f7454726bf0628a66efbd75eb8f9 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Wed, 27 Jun 2018 11:06:02 -0700 Subject: presets: fix importing file with "Official" presets 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libhb') diff --git a/libhb/preset.c b/libhb/preset.c index 4a581e017..6a7f0d122 100644 --- a/libhb/preset.c +++ b/libhb/preset.c @@ -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); -- cgit v1.2.3