remove buggy keybinding dedup

This commit is contained in:
Boris Faure 2016-03-15 19:42:04 +01:00
parent 629e604704
commit bf4a1f4aba
2 changed files with 14 additions and 26 deletions

View File

@ -372,24 +372,6 @@ _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)
{
@ -590,7 +572,7 @@ config_load(const char *key)
_add_key(config, "t", 1, 1, 0, 0, "tab_title");
/*pass through*/
case 9:
_remove_duplicate_keys(config);
/* actually do nothing */
/*pass through*/
case CONF_VER: /* 10 */
config->version = CONF_VER;

View File

@ -742,6 +742,7 @@ _key_binding_free(void *data)
free(kb);
}
/* Returns -2 for duplicate key, 0 on success, -1 otherwise */
int
keyin_add_config(Config_Keys *key)
{
@ -763,7 +764,7 @@ keyin_add_config(Config_Keys *key)
{
_key_binding_free(kb);
ERR("duplicate key '%s'", key->keyname);
return -1;
return -2;
}
return 0;
}
@ -783,11 +784,11 @@ keyin_remove_config(Config_Keys *key)
return 0;
}
int
int
key_bindings_load(Config *config)
{
Config_Keys *key;
Eina_List *l;
Eina_List *l, *l_next;
if (!_key_bindings)
{
@ -812,17 +813,22 @@ key_bindings_load(Config *config)
eina_hash_free_buckets(_key_bindings);
}
EINA_LIST_FOREACH(config->keys, l, key)
EINA_LIST_FOREACH_SAFE(config->keys, l, l_next, key)
{
int res = keyin_add_config(key);
if (res != 0)
return res;
if (res == -2)
{
config->keys = eina_list_remove_list(config->keys, l);
eina_stringshare_del(key->keyname);
eina_stringshare_del(key->cb);
free(key);
}
}
return 0;
}
void
void
key_bindings_shutdown(void)
{
if (_key_bindings)