summaryrefslogtreecommitdiffstats
path: root/gtk/src/presets.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/src/presets.c')
-rw-r--r--gtk/src/presets.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 122756e84..a6ee0f360 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -672,7 +672,7 @@ presets_add_config_file(const gchar *name)
// We can't successfully load presets that were generated by
// a newer version of handbrake than is currently running.
hb_value_free(&preset);
- return -1;
+ return -2;
}
hb_value_t *backup = hb_value_dup(preset);
@@ -1545,12 +1545,25 @@ store_prefs(void)
void
ghb_presets_load(signal_user_data_t *ud)
{
- if (presets_add_config_file("presets.json") < 0)
+ int result = presets_add_config_file("presets.json");
+ if (result == -2)
{
// The above can fail if the presets file was written by a
// more recent version of HandBrake than is currently running.
// Look for a backup version that matches the currently running
// version.
+ GtkWindow *hb_window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window"));
+ gchar *message = g_strdup_printf(
+ _("Presets found are newer than what is supported by this version of HandBrake!\n\n"
+ "Would you like to continue?"));
+ if (!ghb_message_dialog(hb_window, GTK_MESSAGE_WARNING, message,
+ _("Get me out of here!"), _("Load backup presets")))
+ {
+ g_free(message);
+ exit(1);
+ }
+ g_free(message);
+
gchar *name;
int major, minor, micro;
@@ -1559,15 +1572,23 @@ ghb_presets_load(signal_user_data_t *ud)
ghb_log("Failed to read presets file, trying backup (%s)...", name);
if (presets_add_config_file(name) < 0)
{
- if (presets_add_config_file("presets") < 0)
- {
- ghb_log("Failed to read presets file, initailizing new presets...");
- hb_presets_builtin_update();
- store_presets();
- }
+ ghb_log("Failed to read backup presets, using defaults...");
+ hb_presets_builtin_update();
+ // Don't store defaults unless the user explicitely saves
+ // a new preset. This would overwrite the presets file
+ // that was generated by a newer version of HandBrake.
}
g_free(name);
}
+ else if (result < 0)
+ {
+ if (presets_add_config_file("presets") < 0)
+ {
+ ghb_log("Failed to read presets file, initailizing new presets...");
+ hb_presets_builtin_update();
+ store_presets();
+ }
+ }
}
static void