From 798a99b27a86e5c15c6cd21d35e5b3f44332bf7a Mon Sep 17 00:00:00 2001 From: Wedge009 Date: Sun, 18 Oct 2015 00:59:52 +1100 Subject: [PATCH] Avoid polluting preferences file with null commands (Bug #21969) 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. --- src/hotkey/hotkey_item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotkey/hotkey_item.cpp b/src/hotkey/hotkey_item.cpp index 53eb1b1875a2..09fac572d4ae 100644 --- a/src/hotkey/hotkey_item.cpp +++ b/src/hotkey/hotkey_item.cpp @@ -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")); } }