evas: handle object names with a list hash
authorMike Blumenkrantz <zmike@osg.samsung.com>
Thu, 31 Aug 2017 20:13:01 +0000 (16:13 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 1 Sep 2017 17:42:18 +0000 (13:42 -0400)
a canvas can have multiple objects with the same name. assuming that name:obj
is a 1:1 ratio means that name-finding functions are likely to return invalid
objects

@fix

src/lib/evas/canvas/evas_main.c
src/lib/evas/canvas/evas_name.c

index 2b07d3e..246205b 100644 (file)
@@ -221,7 +221,7 @@ _evas_canvas_efl_object_constructor(Eo *eo_obj, Evas_Public_Data *e)
    e->framespace.h = 0;
    e->hinting = EVAS_FONT_HINTING_BYTECODE;
    e->current_event = EVAS_CALLBACK_LAST;
-   e->name_hash = eina_hash_string_superfast_new(NULL);
+   e->name_hash = eina_hash_string_superfast_new((Eina_Free_Cb)eina_list_free);
    eina_clist_init(&e->calc_list);
    eina_clist_init(&e->calc_done);
 
index b02e4a7..798dd8a 100644 (file)
@@ -10,7 +10,7 @@ evas_object_name_set(Evas_Object *eo_obj, const char *name)
    if (obj->name)
      {
         if (obj->layer && obj->layer->evas && obj->layer->evas->name_hash)
-          eina_hash_del(obj->layer->evas->name_hash, obj->name, eo_obj);
+          eina_hash_list_remove(obj->layer->evas->name_hash, obj->name, eo_obj);
         free(obj->name);
      }
    if (!name) obj->name = NULL;
@@ -18,7 +18,7 @@ evas_object_name_set(Evas_Object *eo_obj, const char *name)
      {
         obj->name = strdup(name);
         if (obj->layer && obj->layer->evas && obj->layer->evas->name_hash)
-          eina_hash_add(obj->layer->evas->name_hash, obj->name, eo_obj);
+          eina_hash_list_prepend(obj->layer->evas->name_hash, obj->name, eo_obj);
      }
 }
 
@@ -35,7 +35,7 @@ EOLIAN Evas_Object*
 _evas_canvas_object_name_find(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *name)
 {
    if (!name) return NULL;
-   else return (Evas_Object *)eina_hash_find(e->name_hash, name);
+   else return eina_list_data_get(eina_hash_find(e->name_hash, name));
 }
 
 static Evas_Object *