aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/evas_layer.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-19 15:42:10 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-19 15:43:22 +0900
commitac10a00acc6bacf01bfd208cc78b4eb2a6a925d8 (patch)
tree60eb140098ab49acada076a3c3d735eca4d00090 /src/lib/evas/canvas/evas_layer.c
parenteina rbtree iterator - fix leak found while debugging other problems (diff)
downloadefl-ac10a00acc6bacf01bfd208cc78b4eb2a6a925d8.tar.gz
evas - on shutdown avoid potential invalid memory access
i don't know for sure if this fixes https://phab.enlightenment.org/T4103 but in theory i think it might given a reading of the backtrace and a guess at what might happen, so try this fix. it doesn't hurt and can only help. @fix
Diffstat (limited to 'src/lib/evas/canvas/evas_layer.c')
-rw-r--r--src/lib/evas/canvas/evas_layer.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/src/lib/evas/canvas/evas_layer.c b/src/lib/evas/canvas/evas_layer.c
index 12c8b2fb34..b81c0e0add 100644
--- a/src/lib/evas/canvas/evas_layer.c
+++ b/src/lib/evas/canvas/evas_layer.c
@@ -33,19 +33,25 @@ void
evas_object_release(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, int clean_layer)
{
if (!obj->in_layer) return;
- obj->layer->objects = (Evas_Object_Protected_Data *)eina_inlist_remove(EINA_INLIST_GET(obj->layer->objects), EINA_INLIST_GET(obj));
+ if (!obj->layer->walking_objects)
+ obj->layer->objects = (Evas_Object_Protected_Data *)eina_inlist_remove(EINA_INLIST_GET(obj->layer->objects), EINA_INLIST_GET(obj));
eo_data_unref(eo_obj, obj);
- obj->layer->usage--;
- if (clean_layer)
+ if (!obj->layer->walking_objects)
{
- if (obj->layer->usage <= 0)
+ obj->layer->usage--;
+ if (clean_layer)
{
- evas_layer_del(obj->layer);
- _evas_layer_free(obj->layer);
+ if (obj->layer->usage <= 0)
+ {
+ evas_layer_del(obj->layer);
+ _evas_layer_free(obj->layer);
+ }
}
+ obj->layer = NULL;
+ obj->in_layer = 0;
}
- obj->layer = NULL;
- obj->in_layer = 0;
+ else
+ obj->layer->removes = eina_list_append(obj->layer->removes, obj);
}
Evas_Layer *
@@ -67,15 +73,41 @@ _evas_layer_free(Evas_Layer *lay)
}
void
+_evas_layer_flush_removes(Evas_Layer *lay)
+{
+ if (lay->walking_objects) return;
+ while (lay->removes)
+ {
+ Evas_Object_Protected_Data *obj = lay->removes->data;
+
+ lay->objects = (Evas_Object_Protected_Data *)
+ eina_inlist_remove(EINA_INLIST_GET(lay->objects),
+ EINA_INLIST_GET(obj));
+ lay->removes = eina_list_remove_list(lay->removes, lay->removes);
+ obj->layer = NULL;
+ obj->in_layer = 0;
+ lay->usage--;
+ }
+ if (lay->usage <= 0)
+ {
+ evas_layer_del(lay);
+ _evas_layer_free(lay);
+ }
+}
+
+void
evas_layer_pre_free(Evas_Layer *lay)
{
Evas_Object_Protected_Data *obj;
+ lay->walking_objects++;
EINA_INLIST_FOREACH(lay->objects, obj)
{
if ((!obj->smart.parent) && (!obj->delete_me))
evas_object_del(obj->object);
}
+ lay->walking_objects--;
+ _evas_layer_flush_removes(lay);
}
void