evas: protect against leaking callbacks
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 2 Jan 2020 14:35:31 +0000 (09:35 -0500)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 5 Jan 2020 21:54:53 +0000 (06:54 +0900)
Summary:
when someone accidently does not clean up all his animation callbacks,
we might end up with a lot of errors on console, as we keep delivering
tick events to a dead object.

Reviewers: zmike, cedric, segfaultxavi

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10998

src/lib/evas/canvas/evas_callbacks.c
src/lib/evas/canvas/evas_object_main.c
src/lib/evas/include/evas_private.h

index d9aac15..14ab286 100644 (file)
@@ -872,3 +872,10 @@ evas_object_callbacks_event_catcher_del(Eo *eo_obj EINA_UNUSED, Evas_Object_Prot
      }
 }
 
+void
+evas_object_callbacks_shutdown(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
+{
+   if (obj->animator_ref > 0)
+     efl_event_callback_del(obj->layer->evas->evas, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _animator_repeater, obj);
+   obj->animator_ref = 0;
+}
index 6b78b58..f01ab01 100644 (file)
@@ -1179,7 +1179,7 @@ _efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data
 end:
    evas_object_event_callback_all_del(eo_obj);
    evas_object_event_callback_cleanup(eo_obj);
-
+   evas_object_callbacks_shutdown(eo_obj, obj);
    efl_destructor(efl_super(eo_obj, MY_CLASS));
 }
 
index 4bca07b..cae8624 100755 (executable)
@@ -1630,6 +1630,7 @@ void evas_event_callback_call(Evas *e, Evas_Callback_Type type, void *event_info
 void evas_object_callbacks_finalized(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj);
 void evas_object_callbacks_event_catcher_add(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, const Efl_Callback_Array_Item *array);
 void evas_object_callbacks_event_catcher_del(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, const Efl_Callback_Array_Item *array);
+void evas_object_callbacks_shutdown(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj);
 
 void evas_object_event_callback_call(Evas_Object *obj, Evas_Object_Protected_Data *pd, Evas_Callback_Type type, void *event_info, int event_id, const Efl_Event_Description *efl_event_desc);
 Eina_List *evas_event_objects_event_list(Evas *e, Evas_Object *stop, int x, int y);