billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=1d138fba363c7890becb8033110e2c1f329bba7b

commit 1d138fba363c7890becb8033110e2c1f329bba7b
Author: Boris Faure <bill...@gmail.com>
Date:   Sat Mar 12 16:45:52 2016 +0100

    remove duplicate config keys. Closes T3296
---
 src/bin/config.c | 26 +++++++++++++++++++++++---
 src/bin/keyin.c  |  1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/bin/config.c b/src/bin/config.c
index e04664d..82d858e 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -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)
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index 661080e..8c6d62f 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -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;

-- 


Reply via email to