forked from enlightenment/efl
mapbuf - don't leave the dangling static map pointer that won't be freed.
Some memory profiler tools regard this as the memory leak. it makes engineers waste time to check this. especially app developers.
This commit is contained in:
parent
315d43e29a
commit
60547a9e1b
|
@ -96,8 +96,6 @@ _configure(Evas_Object *obj)
|
|||
ELM_MAPBUF_DATA_GET(obj, sd);
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||
|
||||
static Evas_Map *m = NULL;
|
||||
|
||||
if (!sd->content) return;
|
||||
if (sd->enabled && !evas_object_visible_get(obj)) return;
|
||||
|
||||
|
@ -107,17 +105,18 @@ _configure(Evas_Object *obj)
|
|||
|
||||
if (sd->enabled)
|
||||
{
|
||||
if (!m) m = evas_map_new(4);
|
||||
evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0);
|
||||
if (!sd->map) sd->map = evas_map_new(4);
|
||||
evas_map_util_points_populate_from_geometry(sd->map, x, y, w, h, 0);
|
||||
for (i = 0; i < (int)(sizeof(sd->colors)/sizeof(sd->colors[0])); i++)
|
||||
{
|
||||
evas_map_point_color_set(m, i, sd->colors[i].r, sd->colors[i].g,
|
||||
sd->colors[i].b, sd->colors[i].a);
|
||||
evas_map_point_color_set(sd->map, i, sd->colors[i].r,
|
||||
sd->colors[i].g, sd->colors[i].b,
|
||||
sd->colors[i].a);
|
||||
}
|
||||
|
||||
evas_map_smooth_set(m, sd->smooth);
|
||||
evas_map_alpha_set(m, sd->alpha);
|
||||
evas_object_map_set(sd->content, m);
|
||||
evas_map_smooth_set(sd->map, sd->smooth);
|
||||
evas_map_alpha_set(sd->map, sd->alpha);
|
||||
evas_object_map_set(sd->content, sd->map);
|
||||
evas_object_map_enable_set(sd->content, EINA_TRUE);
|
||||
}
|
||||
else
|
||||
|
@ -275,6 +274,17 @@ _elm_mapbuf_smart_content_unset(Eo *obj, void *_pd, va_list *list)
|
|||
if (ret) *ret = content;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_mapbuf_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||
{
|
||||
Elm_Mapbuf_Smart_Data *priv = _pd;
|
||||
|
||||
ELM_SAFE_FREE(priv->idler, ecore_idler_del);
|
||||
ELM_SAFE_FREE(priv->map, evas_map_free);
|
||||
|
||||
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_mapbuf_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||
{
|
||||
|
@ -325,16 +335,6 @@ _constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
|
|||
evas_obj_type_set(MY_CLASS_NAME_LEGACY));
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||
{
|
||||
Elm_Mapbuf_Smart_Data *priv = _pd;
|
||||
|
||||
ELM_SAFE_FREE(priv->idler, ecore_idler_del);
|
||||
|
||||
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_mapbuf_enabled_set(Evas_Object *obj,
|
||||
Eina_Bool enabled)
|
||||
|
@ -573,9 +573,9 @@ _class_constructor(Eo_Class *klass)
|
|||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
|
||||
|
||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_mapbuf_smart_add),
|
||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_mapbuf_smart_del),
|
||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_RESIZE), _elm_mapbuf_smart_resize),
|
||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_MOVE), _elm_mapbuf_smart_move),
|
||||
EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_mapbuf_smart_show),
|
||||
|
|
|
@ -23,6 +23,7 @@ struct _Elm_Mapbuf_Smart_Data
|
|||
Evas_Object *self;
|
||||
Evas_Object *content;
|
||||
Ecore_Idler *idler;
|
||||
Evas_Map *map;
|
||||
struct
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
|
Loading…
Reference in New Issue