summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kroitor <an.kroitor@samsung.com>2015-05-05 10:46:08 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-05 10:46:13 +0200
commit179e36f5fc9f555e4bc120ffc67534c932505b85 (patch)
tree1c9264dd75925ed7a2f1986abe9921c6526314a1
parent24a5e2cdba13e079080b11ab85fa7e103e424b56 (diff)
edje: _check_recursive_reference reworked to fix segv in Edje_Edit.
Summary: in some cases collections cache "ref" can be NULL and old code fails. Replaced with reliable way of getting part list that was found in _edje_edit_group_references_update @fix Reviewers: raster, Hermet, seoz, reutskiy.v.v, FurryMyad, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2450 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/edje/edje_edit.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index e129ef95d0..1086d64f5f 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -3940,46 +3940,53 @@ edje_edit_part_source_get(Evas_Object *obj, const char *part)
3940static Eina_Bool 3940static Eina_Bool
3941_check_recursive_reference(Edje *ed, const char *source, Eina_List *group_path, Edje_Part *part) 3941_check_recursive_reference(Edje *ed, const char *source, Eina_List *group_path, Edje_Part *part)
3942{ 3942{
3943 unsigned int i;
3944 char *data; 3943 char *data;
3945 Edje_Part_Collection_Directory_Entry *e; 3944 Edje_Part_Collection_Directory_Entry *pce;
3946 Eina_List *l; 3945 Eina_List *l, *part_list, *pll;
3947 Eina_Bool no_ref = EINA_TRUE; 3946 Eina_Bool no_ref = EINA_TRUE;
3947 Eina_Stringshare *part_name, *part_source = NULL;
3948 Edje_Part_Type type;
3948 3949
3949 if (!source) return EINA_TRUE; 3950 if (!source) return EINA_TRUE;
3950 3951
3951 e = eina_hash_find(ed->file->collection, source); 3952 pce = eina_hash_find(ed->file->collection, source);
3952 3953
3953 /* forcing collection load into memory */ 3954 /* forcing collection load into memory */
3954 Evas_Object *part_obj = edje_edit_object_add(ed->base->evas); 3955 Evas_Object *part_obj = edje_edit_object_add(ed->base->evas);
3955 edje_object_file_set(part_obj, ed->file->path, e->entry); 3956 edje_object_file_set(part_obj, ed->file->path, pce->entry);
3956 /* Go through every part to find parts with type GROUP */ 3957 /* Go through every part to find parts with type GROUP */
3957 for (i = 0; i < e->ref->parts_count; ++i) 3958 part_list = edje_edit_parts_list_get(part_obj);
3959 EINA_LIST_FOREACH(part_list, pll, part_name)
3958 { 3960 {
3959 if ((e->ref->parts[i]->type == EDJE_PART_TYPE_GROUP) && 3961 eina_stringshare_del(part_source);
3960 (e->ref->parts[i]->source)) 3962 part_source = edje_edit_part_source_get(part_obj, part_name);
3963 type = edje_edit_part_type_get(part_obj, part_name);
3964 if ((type == EDJE_PART_TYPE_GROUP) && part_source)
3961 { 3965 {
3962 /* Make sure that this group isn't already in the tree of parents */ 3966 /* Make sure that this group isn't already in the tree of parents */
3963 EINA_LIST_FOREACH(group_path, l, data) 3967 EINA_LIST_FOREACH(group_path, l, data)
3964 { 3968 {
3965 if (data == e->ref->parts[i]->source) 3969 if (data == part_source)
3966 { 3970 {
3967 evas_object_del(part_obj); 3971 no_ref = EINA_FALSE;
3968 return EINA_FALSE; 3972 goto end;
3969 } 3973 }
3970 } 3974 }
3971 group_path = eina_list_append(group_path, source); 3975 group_path = eina_list_append(group_path, source);
3972 no_ref &= _check_recursive_reference(ed, e->ref->parts[i]->source, group_path, part); 3976 no_ref &= _check_recursive_reference(ed, part_source, group_path, part);
3973 } 3977 }
3974 3978
3975 /* We did a loop here... this part doesn't have source yet, 3979 /* We did a loop here... this part doesn't have source yet,
3976 but if it will set, it'll be a recursive reference. */ 3980 but if it will set, it'll be a recursive reference. */
3977 if (e->ref->parts[i] == part) 3981 if (!strcmp(part_name, part->name)) /* TODO: check if part->name is also stringshare and values can be compared with == */
3978 { 3982 {
3979 evas_object_del(part_obj); 3983 no_ref = EINA_FALSE;
3980 return EINA_FALSE; 3984 goto end;
3981 } 3985 }
3982 } 3986 }
3987end:
3988 eina_stringshare_del(part_source);
3989 edje_edit_string_list_free(part_list);
3983 evas_object_del(part_obj); 3990 evas_object_del(part_obj);
3984 return no_ref; 3991 return no_ref;
3985} 3992}