summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2014-02-04 10:21:04 +0900
committerChunEon Park <hermet@hermet.pe.kr>2014-02-04 10:27:48 +0900
commitba596f2b0bdd7cf77d66bf75c290397c62121ee3 (patch)
treeaf2a87cf01418a53057258c27b244e6142fd74e9
parenteaa17d1d11c860fc12d5d855d81d940db5967187 (diff)
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.
-rw-r--r--src/lib/elm_mapbuf.c40
-rw-r--r--src/lib/elm_widget_mapbuf.h1
2 files changed, 21 insertions, 20 deletions
diff --git a/src/lib/elm_mapbuf.c b/src/lib/elm_mapbuf.c
index 3aff346e7..29023f0ba 100644
--- a/src/lib/elm_mapbuf.c
+++ b/src/lib/elm_mapbuf.c
@@ -96,8 +96,6 @@ _configure(Evas_Object *obj)
96 ELM_MAPBUF_DATA_GET(obj, sd); 96 ELM_MAPBUF_DATA_GET(obj, sd);
97 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 97 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
98 98
99 static Evas_Map *m = NULL;
100
101 if (!sd->content) return; 99 if (!sd->content) return;
102 if (sd->enabled && !evas_object_visible_get(obj)) return; 100 if (sd->enabled && !evas_object_visible_get(obj)) return;
103 101
@@ -107,17 +105,18 @@ _configure(Evas_Object *obj)
107 105
108 if (sd->enabled) 106 if (sd->enabled)
109 { 107 {
110 if (!m) m = evas_map_new(4); 108 if (!sd->map) sd->map = evas_map_new(4);
111 evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0); 109 evas_map_util_points_populate_from_geometry(sd->map, x, y, w, h, 0);
112 for (i = 0; i < (int)(sizeof(sd->colors)/sizeof(sd->colors[0])); i++) 110 for (i = 0; i < (int)(sizeof(sd->colors)/sizeof(sd->colors[0])); i++)
113 { 111 {
114 evas_map_point_color_set(m, i, sd->colors[i].r, sd->colors[i].g, 112 evas_map_point_color_set(sd->map, i, sd->colors[i].r,
115 sd->colors[i].b, sd->colors[i].a); 113 sd->colors[i].g, sd->colors[i].b,
114 sd->colors[i].a);
116 } 115 }
117 116
118 evas_map_smooth_set(m, sd->smooth); 117 evas_map_smooth_set(sd->map, sd->smooth);
119 evas_map_alpha_set(m, sd->alpha); 118 evas_map_alpha_set(sd->map, sd->alpha);
120 evas_object_map_set(sd->content, m); 119 evas_object_map_set(sd->content, sd->map);
121 evas_object_map_enable_set(sd->content, EINA_TRUE); 120 evas_object_map_enable_set(sd->content, EINA_TRUE);
122 } 121 }
123 else 122 else
@@ -276,6 +275,17 @@ _elm_mapbuf_smart_content_unset(Eo *obj, void *_pd, va_list *list)
276} 275}
277 276
278static void 277static void
278_elm_mapbuf_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
279{
280 Elm_Mapbuf_Smart_Data *priv = _pd;
281
282 ELM_SAFE_FREE(priv->idler, ecore_idler_del);
283 ELM_SAFE_FREE(priv->map, evas_map_free);
284
285 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
286}
287
288static void
279_elm_mapbuf_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 289_elm_mapbuf_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
280{ 290{
281 Elm_Mapbuf_Smart_Data *priv = _pd; 291 Elm_Mapbuf_Smart_Data *priv = _pd;
@@ -325,16 +335,6 @@ _constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
325 evas_obj_type_set(MY_CLASS_NAME_LEGACY)); 335 evas_obj_type_set(MY_CLASS_NAME_LEGACY));
326} 336}
327 337
328static void
329_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
330{
331 Elm_Mapbuf_Smart_Data *priv = _pd;
332
333 ELM_SAFE_FREE(priv->idler, ecore_idler_del);
334
335 eo_do_super(obj, MY_CLASS, eo_destructor());
336}
337
338EAPI void 338EAPI void
339elm_mapbuf_enabled_set(Evas_Object *obj, 339elm_mapbuf_enabled_set(Evas_Object *obj,
340 Eina_Bool enabled) 340 Eina_Bool enabled)
@@ -573,9 +573,9 @@ _class_constructor(Eo_Class *klass)
573{ 573{
574 const Eo_Op_Func_Description func_desc[] = { 574 const Eo_Op_Func_Description func_desc[] = {
575 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), 575 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
576 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
577 576
578 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_mapbuf_smart_add), 577 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_mapbuf_smart_add),
578 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_mapbuf_smart_del),
579 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_RESIZE), _elm_mapbuf_smart_resize), 579 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_RESIZE), _elm_mapbuf_smart_resize),
580 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_MOVE), _elm_mapbuf_smart_move), 580 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_MOVE), _elm_mapbuf_smart_move),
581 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_mapbuf_smart_show), 581 EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_mapbuf_smart_show),
diff --git a/src/lib/elm_widget_mapbuf.h b/src/lib/elm_widget_mapbuf.h
index 2ee9f0432..f4adf22e7 100644
--- a/src/lib/elm_widget_mapbuf.h
+++ b/src/lib/elm_widget_mapbuf.h
@@ -23,6 +23,7 @@ struct _Elm_Mapbuf_Smart_Data
23 Evas_Object *self; 23 Evas_Object *self;
24 Evas_Object *content; 24 Evas_Object *content;
25 Ecore_Idler *idler; 25 Ecore_Idler *idler;
26 Evas_Map *map;
26 struct 27 struct
27 { 28 {
28 int r, g, b, a; 29 int r, g, b, a;