Redesign hotkey migration logic to not rely on monotonically increasing revisions

This commit is contained in:
Thomas Goyne 2013-06-08 18:35:08 -07:00
parent e693fa97ba
commit 9809b66f61
3 changed files with 15 additions and 3 deletions

View File

@ -28,6 +28,8 @@
#include <libaegisub/path.h>
#include <boost/range/algorithm/find.hpp>
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() {

View File

@ -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",

View File

@ -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",