aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-11-20 11:53:45 +0000
committerTom Hacohen <tom@stosb.com>2013-11-20 12:23:18 +0000
commitcad3cf30a48d59bf52c7ed556b71b31495c6eb63 (patch)
treef48d37df07c5c682a66d513ce426598eaff7e304
parenteo - fix _parent_set in base clase when old_parent_pd is NULL (diff)
downloadefl-cad3cf30a48d59bf52c7ed556b71b31495c6eb63.tar.gz
Eo: Check parent is valid in eo_parent_set.
This is an extension to raster's 0355a6a296d8c4a22bf2a2e844a0ba0d4e0abd2e (eo - fix _parent_set in base clase when old_parent_pd is NULL). I also added an error message in case this check fails.
-rw-r--r--src/lib/eo/eo_base_class.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index b553178271..772683c592 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -131,22 +131,34 @@ _parent_set(Eo *obj, void *class_data, va_list *list)
Private_Data *old_parent_pd;
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,
- obj);
+ old_parent_pd->children = eina_list_remove(old_parent_pd->children,
+ obj);
eo_xunref(obj, pd->parent);
}
- pd->parent = parent_id;
- if (pd->parent)
+ /* Set new parent */
+ if (parent_id)
{
Private_Data *parent_pd = NULL;
-
parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS);
- if (parent_pd)
- parent_pd->children = eina_list_append(parent_pd->children,
- obj);
- eo_xref(obj, pd->parent);
+
+ if (EINA_LIKELY(parent_pd != NULL))
+ {
+ 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;
}
}