Elm: fix the widget event callback freeing
authorBruno Dilly <bdilly@profusion.mobi>
Tue, 19 Jun 2012 18:20:38 +0000 (18:20 +0000)
committerBruno Dilly <bdilly@profusion.mobi>
Tue, 19 Jun 2012 18:20:38 +0000 (18:20 +0000)
Removes the event callback list within _smart_del. The current
implementation does not care about the node data resulting on
memory leaks.

Here follows the valgrind log:

16 bytes in 1 blocks are definitely lost in loss record 11 of 168
at 0x4C29DB4: calloc (in
        /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
        by 0x522EC34: elm_widget_event_callback_add (elm_widget.c:1996)
        by 0x5A7AA2B: _edje_emit_handle (edje_program.c:1322)
        by 0x5A766B6: _edje_message_queue_process (edje_message_queue.c:764)
        by 0x5A76856: _edje_job (edje_message_queue.c:160)
        by 0x628C02A: _ecore_job_event_handler (ecore_job.c:115)
        by 0x6288C1F: _ecore_event_call (ecore_private.h:319)
        by 0x628D09B: _ecore_main_loop_iterate_internal (ecore_main.c:1814)
        by 0x628D566: ecore_main_loop_begin (ecore_main.c:931)
        by 0x4023B0: elm_main (test.c:198)

Patch by Leandro Dorileo <dorileo@profusion.mobi>

SVN revision: 72498

src/lib/elm_widget.c

index 71c6b86..ae3167f 100644 (file)
@@ -4715,6 +4715,7 @@ _smart_del(Evas_Object *obj)
 {
    Evas_Object *sobj;
    Elm_Translate_String_Data *ts;
+   Elm_Event_Cb_Data *ecb;
 
    ELM_WIDGET_DATA_GET(obj, sd);
 
@@ -4756,7 +4757,10 @@ _smart_del(Evas_Object *obj)
         eina_stringshare_del(ts->string);
         free(ts);
      }
-   sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
+
+   EINA_LIST_FREE(sd->event_cb, ecb)
+         free(ecb);
+
    if (sd->style) eina_stringshare_del(sd->style);
    if (sd->theme) elm_theme_free(sd->theme);
    _if_focused_revert(obj, EINA_TRUE);