From 9809b66f612d229de3ebbd0b0e064dcc85043c25 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 8 Jun 2013 18:35:08 -0700 Subject: [PATCH] Redesign hotkey migration logic to not rely on monotonically increasing revisions --- aegisub/src/hotkey.cpp | 16 +++++++++++++--- aegisub/src/libresrc/default_config.json | 1 + aegisub/src/libresrc/osx/default_config.json | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/aegisub/src/hotkey.cpp b/aegisub/src/hotkey.cpp index fc9071182..fb6960026 100644 --- a/aegisub/src/hotkey.cpp +++ b/aegisub/src/hotkey.cpp @@ -28,6 +28,8 @@ #include +#include + namespace { const char *removed_commands_7035[] = { 0 }; const char *added_hotkeys_7035[][4] = { @@ -72,11 +74,19 @@ void init() { config::path->Decode("?user/hotkey.json"), GET_DEFAULT_CONFIG(default_hotkey)); - int last_version = OPT_GET("Version/Last Version")->GetInt(); - if (last_version < 7035) + auto migrations = OPT_GET("App/Hotkey Migrations")->GetListString(); + + if (boost::find(migrations, "7035") == end(migrations)) { migrate_hotkeys(removed_commands_7035, added_hotkeys_7035); - if (last_version < 7070) + migrations.emplace_back("7035"); + } + + if (boost::find(migrations, "7070") == end(migrations)) { migrate_hotkeys(removed_commands_7070, added_hotkeys_7070); + migrations.emplace_back("7070"); + } + + OPT_SET("App/Hotkey Migrations")->SetListString(migrations); } void clear() { diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index 2e0b17f98..0058a4d9f 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -10,6 +10,7 @@ }, "Call Tips" : false, "First Start" : true, + "Hotkey Migrations" : [{"string": "placeholder since empty arrays aren't supported"}], "Language" : "", "Maximized" : false, "Save Charset" : "UTF-8", diff --git a/aegisub/src/libresrc/osx/default_config.json b/aegisub/src/libresrc/osx/default_config.json index d57a46b63..11097fc18 100644 --- a/aegisub/src/libresrc/osx/default_config.json +++ b/aegisub/src/libresrc/osx/default_config.json @@ -10,6 +10,7 @@ }, "Call Tips" : false, "First Start" : true, + "Hotkey Migrations" : [{"string": "placeholder since empty arrays aren't supported"}], "Language" : "", "Maximized" : false, "Save Charset" : "UTF-8",