forked from enlightenment/efl
Eo: Check parent is valid in eo_parent_set.
This is an extension to raster's 0355a6a296
(eo - fix _parent_set in base clase when old_parent_pd is NULL).
I also added an error message in case this check fails.
This commit is contained in:
parent
0355a6a296
commit
cad3cf30a4
|
@ -131,22 +131,34 @@ _parent_set(Eo *obj, void *class_data, va_list *list)
|
||||||
Private_Data *old_parent_pd;
|
Private_Data *old_parent_pd;
|
||||||
|
|
||||||
old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS);
|
old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS);
|
||||||
if (old_parent_pd)
|
old_parent_pd->children = eina_list_remove(old_parent_pd->children,
|
||||||
old_parent_pd->children = eina_list_remove(old_parent_pd->children,
|
obj);
|
||||||
obj);
|
|
||||||
eo_xunref(obj, pd->parent);
|
eo_xunref(obj, pd->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
pd->parent = parent_id;
|
/* Set new parent */
|
||||||
if (pd->parent)
|
if (parent_id)
|
||||||
{
|
{
|
||||||
Private_Data *parent_pd = NULL;
|
Private_Data *parent_pd = NULL;
|
||||||
|
|
||||||
parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS);
|
parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS);
|
||||||
if (parent_pd)
|
|
||||||
parent_pd->children = eina_list_append(parent_pd->children,
|
if (EINA_LIKELY(parent_pd != NULL))
|
||||||
obj);
|
{
|
||||||
eo_xref(obj, pd->parent);
|
pd->parent = parent_id;
|
||||||
|
parent_pd->children = eina_list_append(parent_pd->children,
|
||||||
|
obj);
|
||||||
|
eo_xref(obj, pd->parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pd->parent = NULL;
|
||||||
|
ERR("New parent %p for object %p is not a valid Eo object.",
|
||||||
|
parent_id, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pd->parent = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue