evas: Fix potential memleak in event info objects

The new event info being an eo object, it needs to be properly
cleaned. I believe this memleak would not show up much in massif
or other checking tools, as it's a stringshare leak. Also, most
of those event objects will in fact be reused and never deleted.
This commit is contained in:
Jean-Philippe Andre 2016-08-16 14:57:02 +09:00
parent 9673fa66ad
commit c58e293d34
2 changed files with 18 additions and 4 deletions

View File

@ -76,6 +76,22 @@ _efl_event_key_eo_base_constructor(Eo *obj, Efl_Event_Key_Data *pd EINA_UNUSED)
return obj;
}
static inline void
_efl_event_key_free(Efl_Event_Key_Data *pd)
{
eina_stringshare_del(pd->key);
eina_stringshare_del(pd->keyname);
eina_stringshare_del(pd->string);
eina_stringshare_del(pd->compose);
}
EOLIAN static void
_efl_event_key_eo_base_destructor(Eo *obj, Efl_Event_Key_Data *pd)
{
_efl_event_key_free(pd);
eo_destructor(eo_super(obj, MY_CLASS));
}
EOLIAN static void
_efl_event_key_pressed_set(Eo *obj EINA_UNUSED, Efl_Event_Key_Data *pd, Eina_Bool val)
{
@ -151,10 +167,7 @@ _efl_event_key_key_code_get(Eo *obj EINA_UNUSED, Efl_Event_Key_Data *pd)
EOLIAN static void
_efl_event_key_efl_event_reset(Eo *obj EINA_UNUSED, Efl_Event_Key_Data *pd)
{
eina_stringshare_del(pd->key);
eina_stringshare_del(pd->keyname);
eina_stringshare_del(pd->string);
eina_stringshare_del(pd->compose);
_efl_event_key_free(pd);
memset(pd, 0, sizeof(*pd));
pd->eo = obj;
pd->fake = EINA_TRUE;

View File

@ -54,6 +54,7 @@ class Efl.Event.Key (Eo.Base, Efl.Event, Efl.Input.State, Efl.Event.Input)
implements {
class.destructor;
Eo.Base.constructor;
Eo.Base.destructor;
Efl.Event.instance_get;
Efl.Event.reset;
Efl.Event.dup;