remove duplicate config keys. Closes T3296

This commit is contained in:
Boris Faure 2016-03-12 16:45:52 +01:00
parent b8b016875e
commit 1d138fba36
2 changed files with 24 additions and 3 deletions

View File

@ -7,7 +7,7 @@
#include "col.h"
#include "utils.h"
#define CONF_VER 9
#define CONF_VER 10
#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
@ -372,6 +372,23 @@ _add_key(Config *config, const char *name, int ctrl, int alt, int shift,
#undef ADD_KB
static void
_remove_duplicate_keys(Config *config)
{
Eina_Hash * keys = eina_hash_string_superfast_new(NULL);
Eina_List *l, *l_next;
Config_Keys *kb;
EINA_LIST_FOREACH_SAFE(config->keys, l, l_next, kb) {
if (eina_hash_add(keys, kb->cb, NULL) != EINA_TRUE) {
config->keys = eina_list_remove_list(config->keys, l);
eina_stringshare_del(kb->keyname);
eina_stringshare_del(kb->cb);
free(kb);
}
}
eina_hash_free(keys);
}
void
config_default_font_set(Config *config, Evas *evas)
@ -559,7 +576,6 @@ config_load(const char *key)
config->gravatar = EINA_TRUE;
/*pass through*/
case 4:
config->version = 5;
/*pass through*/
case 5:
config->ty_escapes = EINA_TRUE;
@ -573,7 +589,11 @@ config_load(const char *key)
case 8:
_add_key(config, "t", 1, 1, 0, 0, "tab_title");
/*pass through*/
case CONF_VER: /* 9 */
case 9:
_remove_duplicate_keys(config);
/*pass through*/
case CONF_VER: /* 10 */
config->version = CONF_VER;
break;
default:
if (config->version < CONF_VER)

View File

@ -758,6 +758,7 @@ keyin_add_config(Config_Keys *key)
(!eina_hash_direct_add(_key_bindings, kb, kb)))
{
_key_binding_free(kb);
ERR("duplicate key '%s'", key->keyname);
return -1;
}
return 0;