summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2019-09-27 14:19:38 +0900
committerHermet Park <hermetpark@gmail.com>2019-09-27 14:19:38 +0900
commit29beda7f4f365425656e3340ea2da592d00fb52c (patch)
tree75674360fead265341f0b85893ed4726a43e3c5e
parent04a2b7a048f793c6e3c285558785dab7dee63a13 (diff)
evas: fix memory leak with Efl.Canvas.Vg
Summary: It is not correct to change the parent and hope that refcount will work for you. The parent chain is a decision made by the user, not something a widget can touch. Only ref count are to be used when given an outside object. As things where not triggering destruction, there was also no point where the image buffer would be getting to zero and be freed. This commit also fix this. Reviewers: Hermet, zmike Reviewed By: Hermet Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10169
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.c22
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.eo2
2 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.c b/src/lib/evas/canvas/efl_canvas_vg_object.c
index 1f8e05189b..0c8e50bed3 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_object.c
+++ b/src/lib/evas/canvas/efl_canvas_vg_object.c
@@ -145,7 +145,7 @@ _efl_canvas_vg_object_root_node_set(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd, E
145 if (pd->user_entry && pd->user_entry->root) 145 if (pd->user_entry && pd->user_entry->root)
146 { 146 {
147 efl_canvas_vg_node_vg_obj_set(pd->user_entry->root, NULL, NULL); 147 efl_canvas_vg_node_vg_obj_set(pd->user_entry->root, NULL, NULL);
148 efl_parent_set(pd->user_entry->root, NULL); 148 efl_replace(&pd->user_entry->root, NULL);
149 } 149 }
150 150
151 if (root_node) 151 if (root_node)
@@ -160,10 +160,8 @@ _efl_canvas_vg_object_root_node_set(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd, E
160 } 160 }
161 } 161 }
162 pd->user_entry->w = pd->user_entry->h = 0; 162 pd->user_entry->w = pd->user_entry->h = 0;
163 pd->user_entry->root = root_node;
164 163
165 // set the parent so that vg canvas can render it. 164 efl_replace(&pd->user_entry->root, root_node);
166 efl_parent_set(pd->user_entry->root, pd->root);
167 efl_canvas_vg_node_vg_obj_set(root_node, eo_obj, pd); 165 efl_canvas_vg_node_vg_obj_set(root_node, eo_obj, pd);
168 } 166 }
169 else if (pd->user_entry) 167 else if (pd->user_entry)
@@ -333,8 +331,9 @@ _cleanup_reference(void *data, const Efl_Event *event EINA_UNUSED)
333} 331}
334 332
335EOLIAN static void 333EOLIAN static void
336_efl_canvas_vg_object_efl_object_destructor(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd) 334_efl_canvas_vg_object_efl_object_invalidate(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
337{ 335{
336 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
338 Evas *e = evas_object_evas_get(eo_obj); 337 Evas *e = evas_object_evas_get(eo_obj);
339 338
340 efl_event_callback_del(e, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _cleanup_reference, pd); 339 efl_event_callback_del(e, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _cleanup_reference, pd);
@@ -343,11 +342,17 @@ _efl_canvas_vg_object_efl_object_destructor(Eo *eo_obj, Efl_Canvas_Vg_Object_Dat
343 efl_unref(pd->root); 342 efl_unref(pd->root);
344 pd->root = NULL; 343 pd->root = NULL;
345 344
346 if (pd->user_entry) free(pd->user_entry); 345 if (pd->user_entry)
346 {
347 Vg_User_Entry *user_entry = pd->user_entry;
348
349 ENFN->ector_surface_cache_drop(ENC, user_entry->root);
350 free(pd->user_entry);
351 }
347 pd->user_entry = NULL; 352 pd->user_entry = NULL;
348 evas_cache_vg_entry_del(pd->vg_entry); 353 evas_cache_vg_entry_del(pd->vg_entry);
349 354
350 efl_destructor(efl_super(eo_obj, MY_CLASS)); 355 efl_invalidate(efl_super(eo_obj, MY_CLASS));
351} 356}
352 357
353EOLIAN static Eo * 358EOLIAN static Eo *
@@ -364,7 +369,7 @@ _efl_canvas_vg_object_efl_object_constructor(Eo *eo_obj, Efl_Canvas_Vg_Object_Da
364 369
365 /* default root node */ 370 /* default root node */
366 pd->obj = obj; 371 pd->obj = obj;
367 pd->root = efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, NULL); 372 pd->root = efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, eo_obj);
368 373
369 eina_array_step_set(&pd->cleanup, sizeof(pd->cleanup), 8); 374 eina_array_step_set(&pd->cleanup, sizeof(pd->cleanup), 8);
370 375
@@ -375,7 +380,6 @@ static Efl_Object *
375_efl_canvas_vg_object_efl_object_finalize(Eo *obj, Efl_Canvas_Vg_Object_Data *pd) 380_efl_canvas_vg_object_efl_object_finalize(Eo *obj, Efl_Canvas_Vg_Object_Data *pd)
376{ 381{
377 Evas *e = evas_object_evas_get(obj); 382 Evas *e = evas_object_evas_get(obj);
378 efl_parent_set(pd->root, obj);
379 383
380 // TODO: If we start to have to many Evas_Object_VG per canvas, it may be nice 384 // TODO: If we start to have to many Evas_Object_VG per canvas, it may be nice
381 // to actually have one event per canvas and one array per canvas to. 385 // to actually have one event per canvas and one array per canvas to.
diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.eo b/src/lib/evas/canvas/efl_canvas_vg_object.eo
index e414f1aaa7..2213c232ae 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_object.eo
+++ b/src/lib/evas/canvas/efl_canvas_vg_object.eo
@@ -78,7 +78,7 @@ class @beta Efl.Canvas.Vg.Object extends Efl.Canvas.Object implements Efl.File,
78 implements { 78 implements {
79 Efl.Object.constructor; 79 Efl.Object.constructor;
80 Efl.Object.finalize; 80 Efl.Object.finalize;
81 Efl.Object.destructor; 81 Efl.Object.invalidate;
82 Efl.File.load; 82 Efl.File.load;
83 Efl.File.unload; 83 Efl.File.unload;
84 Efl.File.file { set; } 84 Efl.File.file { set; }