summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorVitalii Vorobiov <vi.vorobiov@samsung.com>2015-02-02 11:14:45 +0200
committerVitalii Vorobiov <vi.vorobiov@samsung.com>2015-02-02 11:37:20 +0200
commitbac07e79cea59b1859e23d83028763e3f38c087a (patch)
tree585baad626ee7b2baa72810e8776e5dff9e63c80 /src/lib/edje
parent45aba1343ea30d96e8c4a1b2d9194a2cf65c457f (diff)
Edje: edje_edit - abort Recursive Reference in edje_edit_part_source_set
It is unable to do recursive reference such as: > Having group A with GROUP part that has group B as source. > Having group B with GROUP part that has group A as source. Here we have a loop that is not allowed by edje_cc, so edje_edit also need to check this case. @fix
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/Edje_Edit.h4
-rw-r--r--src/lib/edje/edje_edit.c41
2 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 053a511b78..12db53b4c0 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -1234,6 +1234,10 @@ EAPI const char * edje_edit_part_source_get(Evas_Object *obj, const char *part);
1234 1234
1235/** Set the source of part. 1235/** Set the source of part.
1236 * 1236 *
1237 * If setting source of the part will lead to recursive reference
1238 * (when A source to B, and B is going to be source to A because of this funciton),
1239 * then it will return EINA_FALSE.
1240 *
1237 * @param obj Object being edited. 1241 * @param obj Object being edited.
1238 * @param part Part to set the source of. 1242 * @param part Part to set the source of.
1239 * @param source Value for the source parameter. 1243 * @param source Value for the source parameter.
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 55a262dd31..d19a19aa0f 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -3893,17 +3893,58 @@ edje_edit_part_source_get(Evas_Object *obj, const char *part)
3893 return eina_stringshare_add(rp->part->source); 3893 return eina_stringshare_add(rp->part->source);
3894} 3894}
3895 3895
3896static Eina_Bool
3897_check_recursive_reference(Edje *ed, const char *source, Eina_List *group_path, Edje_Part *part)
3898{
3899 unsigned int i;
3900 char *data;
3901 Edje_Part_Collection_Directory_Entry *e;
3902 Eina_List *l;
3903 Eina_Bool no_ref = EINA_TRUE;
3904
3905 if (!source) return EINA_TRUE;
3906
3907 e = eina_hash_find(ed->file->collection, source);
3908
3909 /* Go through every part to find parts with type GROUP */
3910 for (i = 0; i < e->ref->parts_count; ++i)
3911 {
3912 if ((e->ref->parts[i]->type == EDJE_PART_TYPE_GROUP) &&
3913 (e->ref->parts[i]->source))
3914 {
3915 /* Make sure that this group isn't already in the tree of parents */
3916 EINA_LIST_FOREACH(group_path, l, data)
3917 {
3918 if (data == e->ref->parts[i]->source)
3919 return EINA_FALSE;
3920 }
3921 group_path = eina_list_append(group_path, source);
3922 no_ref &= _check_recursive_reference(ed, e->ref->parts[i]->source, group_path, part);
3923 }
3924
3925 /* We did a loop here... this part doesn't have source yet,
3926 but if it will set, it'll be a recursive reference. */
3927 if (e->ref->parts[i] == part) return EINA_FALSE;
3928 }
3929 return no_ref;
3930}
3931
3896EAPI Eina_Bool 3932EAPI Eina_Bool
3897edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source) 3933edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source)
3898{ 3934{
3899 GET_RP_OR_RETURN(EINA_FALSE); 3935 GET_RP_OR_RETURN(EINA_FALSE);
3900 3936
3901 Evas_Object *child_obj; 3937 Evas_Object *child_obj;
3938 Eina_List *group_path = NULL;
3902 //printf("Set source for part: %s [source: %s]\n", part, source); 3939 //printf("Set source for part: %s [source: %s]\n", part, source);
3903 3940
3904 switch (rp->part->type) 3941 switch (rp->part->type)
3905 { 3942 {
3906 case EDJE_PART_TYPE_GROUP: 3943 case EDJE_PART_TYPE_GROUP:
3944 /* find source group */
3945 if (!_check_recursive_reference(ed, source, group_path, rp->part))
3946 return EINA_FALSE;
3947
3907 if ((rp->typedata.swallow) && (rp->typedata.swallow->swallowed_object)) 3948 if ((rp->typedata.swallow) && (rp->typedata.swallow->swallowed_object))
3908 { 3949 {
3909 _edje_real_part_swallow_clear(ed, rp); 3950 _edje_real_part_swallow_clear(ed, rp);