From: cedric Date: Mon, 15 Jun 2009 14:25:21 +0000 (+0000) Subject: * evas: Fix SEGV when smart object's child come from another layer than X-Git-Tag: accepted/2.0/20130306.225542~242^2~2410 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3013e42ffdbd9100f5fb59920ead4afd11d78f29;p=profile%2Fivi%2Fevas.git * evas: Fix SEGV when smart object's child come from another layer than the parent. When we insert object inside a smart object, they could be attached to another layer. As long as ref counting work, nothing wrong will happen. But during destruction of an Evas, we were just looping over all layers, destroying each of them, without checking for refcounting. This could cause SEGV. This patch introduce a third loop for wiping out all layers after destroying all Evas_Object. So no more SEGV, and no performance regression. Note: Do not rely on evas_object_layer_get on smart object's child, it could give you the wrong answer. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@41046 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/canvas/evas_layer.c b/src/lib/canvas/evas_layer.c index da15d54..241de45 100644 --- a/src/lib/canvas/evas_layer.c +++ b/src/lib/canvas/evas_layer.c @@ -71,7 +71,19 @@ evas_layer_free(Evas_Layer *lay) obj = (Evas_Object *)lay->objects; evas_object_free(obj, 0); } - free(lay); +} + +void +evas_layer_clean(Evas *e) +{ + Evas_Layer *tmp; + + while (e->layers) + { + tmp = e->layers; + evas_layer_del(tmp); + free(tmp); + } } Evas_Layer * @@ -122,6 +134,9 @@ evas_layer_del(Evas_Layer *lay) /** * Sets the layer of the evas that the given object will be part of. + * + * It is not possible to change the layer of a smart object's child. + * * @param obj The given evas object. * @param l The number of the layer to place the object on. */ @@ -170,6 +185,11 @@ evas_object_layer_set(Evas_Object *obj, short l) /** * Retrieves the layer of the evas that the given object is part of. + * + * Be carefull, it doesn't make sense to change the layer of smart object's + * child. So the returned value could be wrong in some case. Don't rely on + * it's accuracy. + * * @param obj The given evas object. * @return Number of the layer. */ diff --git a/src/lib/canvas/evas_main.c b/src/lib/canvas/evas_main.c index 2d2065b..8e07c54 100644 --- a/src/lib/canvas/evas_main.c +++ b/src/lib/canvas/evas_main.c @@ -158,12 +158,10 @@ evas_free(Evas *e) } } } - while (e->layers) - { - lay = e->layers; - evas_layer_del(lay); - evas_layer_free(lay); - } + EINA_INLIST_FOREACH(e->layers, lay) + evas_layer_free(lay); + evas_layer_clean(e); + e->walking_list--; evas_font_path_clear(e); diff --git a/src/lib/include/evas_private.h b/src/lib/include/evas_private.h index 7304966..87e9134 100644 --- a/src/lib/include/evas_private.h +++ b/src/lib/include/evas_private.h @@ -718,6 +718,7 @@ void evas_object_recalc_clippees(Evas_Object *obj); Evas_Layer *evas_layer_new(Evas *e); void evas_layer_pre_free(Evas_Layer *lay); void evas_layer_free(Evas_Layer *lay); +void evas_layer_clean(Evas *e); Evas_Layer *evas_layer_find(Evas *e, short layer_num); void evas_layer_add(Evas_Layer *lay); void evas_layer_del(Evas_Layer *lay);