summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-05-19 16:39:48 -0600
committerJohn Stebbins <[email protected]>2016-05-19 16:39:48 -0600
commit1e9cd570b02f9bfca8e2364ad0c083705851d6fe (patch)
tree6efcb3a3c9a6f623e270a92a975736be6d916333 /gtk/src
parente2bd6cc4b01fee16dcc52d193494e640ab16c496 (diff)
LinGui: save backup of presets whenever the version changes
... and not only when the version increases. This ensures that presets from a newer version are not lost when temporarily reverting to an older version.
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/presets.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 69d02922e..be2b893dd 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -679,6 +679,17 @@ presets_add_config_file(const gchar *name)
int major, minor, micro;
hb_presets_version(preset, &major, &minor, &micro);
hb_presets_current_version(&hb_major, &hb_minor, &hb_micro);
+ if (major != hb_major)
+ {
+ // Make a backup whenever the preset version changes
+ config = ghb_get_user_config_dir(NULL);
+ path = g_strdup_printf ("%s/presets.%d.%d.%d.json",
+ config, major, minor, micro);
+ hb_value_write_json(preset, path);
+ g_free(config);
+ g_free(path);
+ }
+
if (major > hb_major)
{
// Change in major indicates non-backward compatible preset changes.
@@ -689,19 +700,7 @@ presets_add_config_file(const gchar *name)
}
hb_value_t *imported;
- int result = hb_presets_import(preset, &imported);
- if (result)
- {
- // hb_presets_import modified the preset. So make a backup
- // of the original.
- config = ghb_get_user_config_dir(NULL);
- path = g_strdup_printf ("%s/presets.%d.%d.%d.json",
- config, major, minor, micro);
- hb_value_write_json(preset, path);
- g_free(config);
- g_free(path);
- }
-
+ hb_presets_import(preset, &imported);
hb_presets_add(imported);
if (major != hb_major || minor != hb_minor || micro != hb_micro)
{