summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2015-01-07 11:42:08 +0900
committerChunEon Park <hermet@hermet.pe.kr>2015-01-07 11:42:38 +0900
commit4f1fd4ca4c53b2703da20650fc160b8f9ac24ed1 (patch)
treeaa94557cc9acc43d1071fe49daefbc18519139de
parent1063490cd9d2039e1525808fcbe0cc58d3ec5480 (diff)
downloadelementary-4f1fd4ca4c53b2703da20650fc160b8f9ac24ed1.tar.gz
colorselector: memory leak fix in _color_bars_add
Summary: this function is called at least twice: in _smart_add and every time _theme_apply is called. so we need either correctly free sd->cb_data or reuse it @fix Reviewers: seoz, cedric, raster, Hermet Subscribers: reutskiy.v.v Projects: #elementary Differential Revision: https://phab.enlightenment.org/D1841
-rw-r--r--src/lib/elm_colorselector.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index b851208fe..369cca1c0 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -925,7 +925,7 @@ _color_bars_add(Evas_Object *obj)
for (i = 0; i < 4; i++)
{
- sd->cb_data[i] = ELM_NEW(Color_Bar_Data);
+ if (!sd->cb_data[i]) sd->cb_data[i] = ELM_NEW(Color_Bar_Data);
sd->cb_data[i]->parent = obj;
switch (i)
@@ -948,7 +948,7 @@ _color_bars_add(Evas_Object *obj)
}
/* load colorbar area */
- sd->cb_data[i]->colorbar = edje_object_add(e);
+ if (!sd->cb_data[i]->colorbar) sd->cb_data[i]->colorbar = edje_object_add(e);
elm_widget_theme_object_set
(obj, sd->cb_data[i]->colorbar, "colorselector", "base",
elm_widget_style_get(obj));
@@ -961,7 +961,7 @@ _color_bars_add(Evas_Object *obj)
elm_widget_sub_object_add(obj, sd->cb_data[i]->colorbar);
/* load colorbar image */
- sd->cb_data[i]->bar = edje_object_add(e);
+ if (!sd->cb_data[i]->bar) sd->cb_data[i]->bar = edje_object_add(e);
snprintf(buf, sizeof(buf), "%s/%s", colorbar_name,
elm_widget_style_get(obj));
elm_widget_theme_object_set
@@ -971,7 +971,7 @@ _color_bars_add(Evas_Object *obj)
elm_widget_sub_object_add(obj, sd->cb_data[i]->bar);
/* provide expanded touch area */
- sd->cb_data[i]->touch_area = evas_object_rectangle_add(e);
+ if (!sd->cb_data[i]->touch_area) sd->cb_data[i]->touch_area = evas_object_rectangle_add(e);
evas_object_color_set(sd->cb_data[i]->touch_area, 0, 0, 0, 0);
edje_object_part_swallow
(sd->cb_data[i]->colorbar, "elm.arrow_bg",
@@ -989,7 +989,7 @@ _color_bars_add(Evas_Object *obj)
changing color of the opacity bar */
if ((i == 1) || (i == 2))
{
- sd->cb_data[i]->bg_rect = evas_object_rectangle_add(e);
+ if (!sd->cb_data[i]->bg_rect) sd->cb_data[i]->bg_rect = evas_object_rectangle_add(e);
evas_object_color_set
(sd->cb_data[i]->bg_rect, sd->er, sd->eg, sd->eb, 255);
edje_object_part_swallow
@@ -1000,7 +1000,7 @@ _color_bars_add(Evas_Object *obj)
}
if (i == 3)
{
- sd->cb_data[i]->bg_rect = edje_object_add(e);
+ if (!sd->cb_data[i]->bg_rect) sd->cb_data[i]->bg_rect = edje_object_add(e);
snprintf(buf, sizeof(buf), "%s/%s", colorbar_name,
elm_widget_style_get(obj));
elm_widget_theme_object_set
@@ -1015,7 +1015,7 @@ _color_bars_add(Evas_Object *obj)
}
/* load arrow image, pointing the colorbar */
- sd->cb_data[i]->arrow = edje_object_add(e);
+ if (!sd->cb_data[i]->arrow) sd->cb_data[i]->arrow = edje_object_add(e);
elm_widget_theme_object_set
(obj, sd->cb_data[i]->arrow, "colorselector", "arrow",
elm_widget_style_get(obj));
@@ -1031,7 +1031,7 @@ _color_bars_add(Evas_Object *obj)
(sd->cb_data[i]->arrow, sd->er, sd->eg, sd->eb, 255);
/* load left button */
- sd->cb_data[i]->lbt = elm_button_add(obj);
+ if (!sd->cb_data[i]->lbt) sd->cb_data[i]->lbt = elm_button_add(obj);
snprintf(buf, sizeof(buf), "colorselector/left/%s",
elm_widget_style_get(obj));
elm_object_style_set(sd->cb_data[i]->lbt, buf);
@@ -1051,7 +1051,7 @@ _color_bars_add(Evas_Object *obj)
sd->cb_data[i]);
/* load right button */
- sd->cb_data[i]->rbt = elm_button_add(obj);
+ if (!sd->cb_data[i]->rbt) sd->cb_data[i]->rbt = elm_button_add(obj);
snprintf(buf, sizeof(buf), "colorselector/right/%s",
elm_widget_style_get(obj));
elm_object_style_set(sd->cb_data[i]->rbt, buf);