From fe70f0c080d2f168b5674cd4aa804ec95617739d Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Thu, 31 Dec 2015 13:49:56 +0900 Subject: [PATCH] edje: enhance circular dependency error message of edje calculation Summary: enhance error message of edje calculation Test Plan: check edje having circular dependency Reviewers: raster, cedric, jpeg Subscribers: seoz Differential Revision: https://phab.enlightenment.org/D3484 --- src/lib/edje/edje_calc.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 0505580..d516348 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -3614,6 +3614,117 @@ _edje_map_prop_set(Evas_Map *map, const Edje_Calc_Params *pf, #define Rel1Y 1 #define Rel2X 2 #define Rel2Y 3 +Eina_Bool circular_dependency_find(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part *cep, Eina_List **clist) +{ + Edje_Real_Part *rp = NULL; + + if (cep && !strcmp(ep->part->name, cep->part->name)) + { + return EINA_TRUE; + } + + if ((ep->calculating & FLAG_X)) + { + if (ep->param1.description) + { + if (ep->param1.description->rel1.id_x >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param1.description->rel1.id_x]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + if (ep->param1.description->rel2.id_x >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param1.description->rel2.id_x]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + } + + if (ep->param2) + { + if (ep->param2->description->rel1.id_x >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param2->description->rel1.id_x]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + if (ep->param2->description->rel2.id_x >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param2->description->rel2.id_x]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + } + } + if ((ep->calculating & FLAG_Y)) + { + if (ep->param1.description) + { + if (ep->param1.description->rel1.id_y >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param1.description->rel1.id_y]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + if (ep->param1.description->rel2.id_y >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param1.description->rel2.id_y]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + } + if (ep->param2) + { + if (ep->param2->description->rel1.id_y >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param2->description->rel1.id_y]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + if (ep->param2->description->rel2.id_y >= 0) + { + if (!cep) cep = ep; + rp = ed->table_parts[cep->param2->description->rel2.id_y]; + if (circular_dependency_find(ed, ep, rp, clist)) + { + *clist = eina_list_prepend(*clist, rp->part->name); + return EINA_TRUE; + } + } + } + } + + return EINA_FALSE; +} void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state) @@ -3686,6 +3797,23 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta ep->part->name, axes, ep->calculating, faxes, flags); + + Eina_List *clist = NULL; + Eina_List *l = NULL; + char *part_name; + char depends_path[PATH_MAX] = ""; + circular_dependency_find(ed, ep, NULL, &clist); + strncat(depends_path, ep->part->name, + sizeof(ep->part->name) - strlen(ep->part->name) - 1); + EINA_LIST_FOREACH(clist, l, part_name) + { + strncat(depends_path, " -> ", + sizeof(depends_path) - strlen(depends_path) - 1); + strncat(depends_path, part_name, + sizeof(depends_path) - strlen(depends_path) - 1); + } + ERR("Circular dependency: %s", depends_path); + eina_list_free(clist); #endif return; } -- 2.7.4