From c2cf2cde694a7fba980a074d491d7bb522ae2d5b Mon Sep 17 00:00:00 2001 From: cedric Date: Thu, 20 Jan 2011 13:03:09 +0000 Subject: [PATCH] * edje: fix bug when targetting external, table and box items reported by yoz and watchwolf. WARNING: IT SHOULD BE JUST A FIX, TRIED AND TESTED, BUT COULD BREAK YOUR APPS, PLEASE TEST ASAP AND REPORT TO ME: cedric.bail@free.fr ! git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@56241 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/edje_private.h | 5 +- src/lib/edje_program.c | 35 +++++++------- src/lib/edje_util.c | 123 ++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 129 insertions(+), 34 deletions(-) diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 4612043..4611e04 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -1493,8 +1493,9 @@ const char * _edje_text_class_font_get(Edje *ed, int *size, char **free_later); -Edje_Real_Part *_edje_real_part_get(Edje *ed, const char *part); -Edje_Real_Part *_edje_real_part_recursive_get(Edje *ed, const char *part); +Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part); +Edje_Real_Part *_edje_real_part_recursive_get(const Edje *ed, const char *part); +Edje *_edje_recursive_get(Edje *ed, const char *part, Edje_Real_Part **orp); Edje_Color_Class *_edje_color_class_find(Edje *ed, const char *color_class); void _edje_color_class_member_add(Edje *ed, const char *color_class); void _edje_color_class_member_del(Edje *ed, const char *color_class); diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c index bb442a7..fb6fb43 100644 --- a/src/lib/edje_program.c +++ b/src/lib/edje_program.c @@ -1008,7 +1008,8 @@ _edje_emit(Edje *ed, const char *sig, const char *src) */ if (sep) { - Edje_Real_Part *rp; + Edje_Real_Part *rp = NULL; + Edje *ed2; char *newsig; size_t length; char *part; @@ -1025,24 +1026,20 @@ _edje_emit(Edje *ed, const char *sig, const char *src) *newsig = '\0'; newsig++; - rp = _edje_real_part_recursive_get(ed, part); - if (rp && rp->part) + ed2 = _edje_recursive_get(ed, part, &rp); + if (ed2) + { + if (ed2) _edje_emit(ed2, newsig, src); + return; /* stop processing. + * XXX maybe let signal be processed anyway? + * XXX in this case, just comment this line + */ + } + + if (rp) { switch (rp->part->type) { - case EDJE_PART_TYPE_GROUP: - { - Edje *ed2; - - if (!rp->swallowed_object) break ; - - ed2 = _edje_fetch(rp->swallowed_object); - if (ed2) _edje_emit(ed2, newsig, src); - return; /* stop processing. - * XXX maybe let signal be processed anyway? - * XXX in this case, just comment this line - */ - } case EDJE_PART_TYPE_EXTERNAL: { if (!rp->swallowed_object) break ; @@ -1056,8 +1053,14 @@ _edje_emit(Edje *ed, const char *sig, const char *src) _edje_emit(rp->edje, newsig, src); return; } + default: + fprintf(stderr, "SPANK SPANK SPANK !!!\nYou should never be here !\n"); + break; } } + + *(newsig - 1) = EDJE_PART_PATH_SEPARATOR; + fprintf(stderr, "Not handle: '%s', '%s' !\n", sig, src); } emsg.sig = sig; diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index 9b8e8ec..79e5a59 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -37,7 +37,8 @@ static Eina_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void static void _edje_object_image_preload_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _edje_object_signal_preload_cb(void *data, Evas_Object *obj, const char *emission, const char *source); -Edje_Real_Part *_edje_real_part_recursive_get_helper(Edje *ed, char **path); +Edje_Real_Part *_edje_real_part_recursive_get_helper(const Edje *ed, char **path); +static Edje *_edje_recursive_get_helper(Edje *ed, char **path, Edje_Real_Part **orp); /************************** API Routines **************************/ @@ -4357,7 +4358,7 @@ _edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear) } Edje_Real_Part * -_edje_real_part_recursive_get(Edje *ed, const char *part) +_edje_real_part_recursive_get(const Edje *ed, const char *part) { Edje_Real_Part *rp; char **path; @@ -4373,6 +4374,23 @@ _edje_real_part_recursive_get(Edje *ed, const char *part) return rp; } +Edje * +_edje_recursive_get(Edje *ed, const char *part, Edje_Real_Part **orp) +{ + Edje *oed; + char **path; + + path = eina_str_split(part, EDJE_PART_PATH_SEPARATOR_STRING, 0); + if (!path) return NULL; + + //printf("recursive get: %s\n", part); + oed = _edje_recursive_get_helper(ed, path, orp); + + free(*path); + free(path); + return oed; +} + Evas_Object * _edje_children_get(Edje_Real_Part *rp, const char *partid) { @@ -4422,16 +4440,22 @@ _edje_children_get(Edje_Real_Part *rp, const char *partid) } Edje_Real_Part * -_edje_real_part_recursive_get_helper(Edje *ed, char **path) +_edje_real_part_recursive_get_helper(const Edje *ed, char **path) { Edje_Real_Part *rp; Evas_Object *child; const char *alias = NULL; char *idx = NULL; + if (ed->collection && ed->collection->alias) + alias = eina_hash_find(ed->collection->alias, path[0]); + + if (!alias) + alias = path[0]; + //printf(" lookup: %s on %s\n", path[0], ed->parent ? ed->parent : "-"); - if (path[0]) - idx = strchr(path[0], EDJE_PART_PATH_SEPARATOR_INDEXL); + if (alias) + idx = strchr(alias, EDJE_PART_PATH_SEPARATOR_INDEXL); if (idx) { char *end; @@ -4445,18 +4469,16 @@ _edje_real_part_recursive_get_helper(Edje *ed, char **path) } } - if (ed->collection && ed->collection->alias) - alias = eina_hash_find(ed->collection->alias, path[0]); - if (alias) + if (alias != path[0]) { rp = _edje_real_part_recursive_get(ed, alias); - if (!path[1]) return rp; + if (!path[1] && !idx) return rp; if (!rp) return NULL; } else { rp = _edje_real_part_get(ed, path[0]); - if (!path[1]) return rp; + if (!path[1] && !idx) return rp; if (!rp) return NULL; } @@ -4478,20 +4500,89 @@ _edje_real_part_recursive_get_helper(Edje *ed, char **path) ed = _edje_fetch(child); if (!ed) return NULL; - if ((rp = _edje_real_part_recursive_get_helper(ed, path))) - return rp; - - return NULL; + return _edje_real_part_recursive_get_helper(ed, path); default: return NULL; } } - /* Private Routines */ +static Edje * +_edje_recursive_get_helper(Edje *ed, char **path, Edje_Real_Part **orp) +{ + Evas_Object *child; + Edje_Real_Part *rp; + const char *alias = NULL; + char *idx = NULL; + + if (ed->collection && ed->collection->alias) + alias = eina_hash_find(ed->collection->alias, path[0]); + + if (!alias) + alias = path[0]; + + //printf(" lookup: %s on %s\n", path[0], ed->parent ? ed->parent : "-"); + if (alias) + idx = strchr(alias, EDJE_PART_PATH_SEPARATOR_INDEXL); + if (idx) + { + char *end; + + end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR); + if (end) + { + *end = '\0'; + *idx = '\0'; + idx++; + } + } + + if (alias != path[0]) + { + rp = _edje_real_part_recursive_get(ed, alias); + if (!rp) return NULL; + if (!path[1] && !idx) return rp->edje; + } + else + { + rp = _edje_real_part_get(ed, path[0]); + if (!rp) return NULL; + if (!path[1] && !idx) return rp->edje; + } + + switch (rp->part->type) + { + case EDJE_PART_TYPE_GROUP: + if (!rp->swallowed_object) return NULL; + ed = _edje_fetch(rp->swallowed_object); + if (!ed) return NULL; + path++; + + if (!path[0]) return ed; + return _edje_recursive_get_helper(ed, path, orp); + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + case EDJE_PART_TYPE_EXTERNAL: + if (!idx) + { + *orp = rp; + return NULL; + } + path++; + + child = _edje_children_get(rp, idx); + + ed = _edje_fetch(child); + if (!ed) return NULL; + if (!path[0]) return ed; + return _edje_recursive_get_helper(ed, path, orp); + default: + return NULL; + } +} Edje_Real_Part * -_edje_real_part_get(Edje *ed, const char *part) +_edje_real_part_get(const Edje *ed, const char *part) { unsigned int i; -- 2.7.4