Skip to content

Commit

Permalink
Avoid polluting preferences file with null commands (Bug #21969)
Browse files Browse the repository at this point in the history
Only save non-default hot-keys to the preferences file if the hot-key is active (ie command != 'null').

Clearing hot-keys in memory (via the hot-key functions in the game) only sets the command to 'null', which currently gets written to the preferences file if it is a custom, ie non-default, hot-key. Over time, creating and clearing hot-keys results in a lot of redundant hot-key entries. The nice thing about this update is that it will remove redundant command='null' entries for existing preferences files as well as prevent it from being included in future ones..

I am making this change against the sdl2 branch instead of master because the sdl2 branch already contains a lot of rewriting of the hot-key functionality. Testing against master was also hopeless because hot-key handling is still rather broken building against SDL 1.2.
  • Loading branch information
Wedge009 committed Feb 27, 2016
1 parent d5b20f9 commit 798a99b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hotkey/hotkey_item.cpp
Expand Up @@ -462,7 +462,7 @@ void save_hotkeys(config& cfg)
cfg.clear_children("hotkey");

BOOST_FOREACH(hotkey_ptr item, hotkeys_) {
if (!item->is_default()) {
if (!item->is_default() && item->active()) {
item->save(cfg.add_child("hotkey"));
}
}
Expand Down

0 comments on commit 798a99b

Please sign in to comment.