diff options
author | Vitalii Vorobiov <vi.vorobiov@samsung.com> | 2015-01-29 21:21:05 +0100 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-01-29 21:21:08 +0100 |
commit | ac0b42a51a756ab15416aadeeb053eff7ed77d53 (patch) | |
tree | eb75ff208e248f57c9f331165f0804aa45cba48f /src/bin/edje | |
parent | b457dff840ff1e0e1c278b9aa492628f025422c3 (diff) |
Edje: edje_cc - abort recursive Reference that is made by GROUP parts
Summary:
It is easy to create edj collections that aren't working at all and
edje_cc easily allows user to do that.
For example:
> Having group A with GROUP part that has group B as source.
> Having group B with GROUP part that has group A as source.
In this case edje_cc compile source code perfectly, but if user try to load
this edje as layout or use together with edje_edit it will cause unexpacted
and wrong behaviour.
@fix
Reviewers: seoz, Hermet, reutskiy.v.v, cedric
Reviewed By: cedric
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D1908
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/bin/edje')
-rwxr-xr-x | src/bin/edje/edje_cc_out.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index 19edf9420c..4f582c779c 100755 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c | |||
@@ -369,6 +369,51 @@ check_image_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, | |||
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | /* This function check loops between groups. | ||
373 | For example: | ||
374 | > part in group A. It's source is B. | ||
375 | > part in group B. It's source is C. | ||
376 | > part in group C. It's source is A <- here is error. | ||
377 | It's loop that we need to avoid! */ | ||
378 | static void | ||
379 | check_source_links(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef, Eina_List *group_path) | ||
380 | { | ||
381 | unsigned int i; | ||
382 | char *data; | ||
383 | Edje_Part_Collection *pc_source; | ||
384 | Eina_List *l; | ||
385 | |||
386 | EINA_LIST_FOREACH(edje_collections, l, pc_source) | ||
387 | { | ||
388 | /* Find sourced group */ | ||
389 | if (strcmp(ep->source, pc_source->part) == 0) | ||
390 | { | ||
391 | /* Go through every part to find parts with type GROUP */ | ||
392 | for (i = 0; i < pc_source->parts_count; ++i) | ||
393 | { | ||
394 | if ((pc_source->parts[i]->type == EDJE_PART_TYPE_GROUP) && | ||
395 | (pc_source->parts[i]->source)) | ||
396 | { | ||
397 | /* Make sure that this group isn't already in the tree of parents */ | ||
398 | EINA_LIST_FOREACH(group_path, l, data) | ||
399 | { | ||
400 | if (data == pc_source->parts[i]->source) | ||
401 | { | ||
402 | error_and_abort(ef,"Recursive loop group '%s' " | ||
403 | "already included inside " | ||
404 | "part '%s' of group '%s'", | ||
405 | data, pc_source->parts[i]->name, | ||
406 | pc->part); | ||
407 | } | ||
408 | } | ||
409 | group_path = eina_list_append(group_path, ep->source); | ||
410 | check_source_links(pc, pc_source->parts[i], ef, group_path); | ||
411 | } | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | } | ||
416 | |||
372 | static void | 417 | static void |
373 | check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) | 418 | check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) |
374 | { | 419 | { |
@@ -410,6 +455,7 @@ static void | |||
410 | check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) | 455 | check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) |
411 | { | 456 | { |
412 | unsigned int i; | 457 | unsigned int i; |
458 | Eina_List *group_path = NULL; | ||
413 | /* FIXME: check image set and sort them. */ | 459 | /* FIXME: check image set and sort them. */ |
414 | if (!ep->default_desc) | 460 | if (!ep->default_desc) |
415 | error_and_abort(ef, "Collection %i: default description missing " | 461 | error_and_abort(ef, "Collection %i: default description missing " |
@@ -428,6 +474,8 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) | |||
428 | else if ((ep->type == EDJE_PART_TYPE_BOX) || | 474 | else if ((ep->type == EDJE_PART_TYPE_BOX) || |
429 | (ep->type == EDJE_PART_TYPE_TABLE)) | 475 | (ep->type == EDJE_PART_TYPE_TABLE)) |
430 | check_packed_items(pc, ep, ef); | 476 | check_packed_items(pc, ep, ef); |
477 | else if (ep->type == EDJE_PART_TYPE_GROUP) | ||
478 | check_source_links(pc, ep, ef, group_path); | ||
431 | 479 | ||
432 | /* FIXME: When mask are supported remove this check */ | 480 | /* FIXME: When mask are supported remove this check */ |
433 | if (ep->clip_to_id != -1 && | 481 | if (ep->clip_to_id != -1 && |