summaryrefslogtreecommitdiff
path: root/src/edje_external
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-06-26 19:42:21 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-06-26 23:11:55 +0200
commit7352bcff98fc65a08edcd505b872403af8d821a7 (patch)
tree98e30d0ea5a9ed9e79f99aedc4dd5c1c1e98d9a3 /src/edje_external
parente3331751098fab7463cee8782ca72dcba92a8f09 (diff)
edje_external: fix external icon handling
External icons were handled with a global variable, which reason to exist seem quite weird. It seems to me it was used to retain some states of the actual parameters to get them later without having access to the real parameters. I don't really get how this would have worked with more than one icon. When I tried to animate an external icon, with two states, there were leaks and memory corruption... Now both are gone. @fix
Diffstat (limited to 'src/edje_external')
-rw-r--r--src/edje_external/elementary/elm_icon.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/src/edje_external/elementary/elm_icon.c b/src/edje_external/elementary/elm_icon.c
index 979cc0b..9e9f6dd 100644
--- a/src/edje_external/elementary/elm_icon.c
+++ b/src/edje_external/elementary/elm_icon.c
@@ -20,7 +20,6 @@ typedef struct _Elm_Params_Icon
20 const char *icon; 20 const char *icon;
21} Elm_Params_Icon; 21} Elm_Params_Icon;
22 22
23static Elm_Params_Icon *param_icon;
24 23
25static void 24static void
26external_icon_state_set(void *data EINA_UNUSED, Evas_Object *obj, 25external_icon_state_set(void *data EINA_UNUSED, Evas_Object *obj,
@@ -30,6 +29,7 @@ external_icon_state_set(void *data EINA_UNUSED, Evas_Object *obj,
30 const Elm_Params_Icon *p; 29 const Elm_Params_Icon *p;
31 Evas_Object *edje; 30 Evas_Object *edje;
32 const char *file; 31 const char *file;
32 Eina_Bool param;
33 33
34 if (to_params) p = to_params; 34 if (to_params) p = to_params;
35 else if (from_params) p = from_params; 35 else if (from_params) p = from_params;
@@ -38,46 +38,39 @@ external_icon_state_set(void *data EINA_UNUSED, Evas_Object *obj,
38 if (p->file) 38 if (p->file)
39 { 39 {
40 elm_image_file_set(obj, p->file, NULL); 40 elm_image_file_set(obj, p->file, NULL);
41 param_icon->file = p->file;
42 } 41 }
43 if (p->smooth_exists) 42 if (p->smooth_exists)
44 { 43 {
45 elm_image_smooth_set(obj, p->smooth); 44 elm_image_smooth_set(obj, p->smooth);
46 param_icon->smooth = p->smooth;
47 } 45 }
48 if (p->no_scale_exists) 46 if (p->no_scale_exists)
49 { 47 {
50 elm_image_no_scale_set(obj, p->no_scale); 48 elm_image_no_scale_set(obj, p->no_scale);
51 param_icon->no_scale = p->no_scale;
52 } 49 }
53 if (p->scale_up_exists && p->scale_down_exists) 50 if (p->scale_up_exists && p->scale_down_exists)
54 { 51 {
55 elm_image_resizable_set(obj, p->scale_up, p->scale_down); 52 elm_image_resizable_set(obj, p->scale_up, p->scale_down);
56 param_icon->scale_up = p->scale_up;
57 param_icon->scale_down = p->scale_down;
58 } 53 }
59 else if (p->scale_up_exists || p->scale_down_exists) 54 else if (p->scale_up_exists || p->scale_down_exists)
60 { 55 {
61 if (p->scale_up_exists) 56 if (p->scale_up_exists)
62 { 57 {
63 elm_image_resizable_set(obj, p->scale_up, param_icon->scale_down); 58 elm_image_resizable_get(obj, NULL, &param);
64 param_icon->scale_up = p->scale_up; 59 elm_image_resizable_set(obj, p->scale_up, param);
65 } 60 }
66 else 61 else
67 { 62 {
68 elm_image_resizable_set(obj, param_icon->scale_up, p->scale_down); 63 elm_image_resizable_get(obj, &param, NULL);
69 param_icon->scale_down = p->scale_down; 64 elm_image_resizable_set(obj, param, p->scale_down);
70 } 65 }
71 } 66 }
72 if (p->fill_outside_exists) 67 if (p->fill_outside_exists)
73 { 68 {
74 elm_image_fill_outside_set(obj, p->fill_outside); 69 elm_image_fill_outside_set(obj, p->fill_outside);
75 param_icon->fill_outside = p->fill_outside;
76 } 70 }
77 if (p->prescale_size_exists) 71 if (p->prescale_size_exists)
78 { 72 {
79 elm_image_prescale_set(obj, p->prescale_size); 73 elm_image_prescale_set(obj, p->prescale_size);
80 param_icon->prescale_size = p->prescale_size;
81 } 74 }
82 if (p->icon) 75 if (p->icon)
83 { 76 {
@@ -103,55 +96,49 @@ external_icon_param_set(void *data EINA_UNUSED, Evas_Object *obj,
103{ 96{
104 Evas_Object *edje; 97 Evas_Object *edje;
105 const char *file; 98 const char *file;
99 Eina_Bool p;
106 100
107 if (!strcmp(param->name, "file") 101 if (!strcmp(param->name, "file")
108 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) 102 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
109 { 103 {
110 Eina_Bool ret = elm_image_file_set(obj, param->s, NULL); 104 return elm_image_file_set(obj, param->s, NULL);
111 if (ret)
112 param_icon->file = param->s;
113 return ret;
114 } 105 }
115 else if (!strcmp(param->name, "smooth") 106 else if (!strcmp(param->name, "smooth")
116 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 107 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
117 { 108 {
118 elm_image_smooth_set(obj, param->i); 109 elm_image_smooth_set(obj, param->i);
119 param_icon->smooth = param->i;
120 return EINA_TRUE; 110 return EINA_TRUE;
121 } 111 }
122 else if (!strcmp(param->name, "no scale") 112 else if (!strcmp(param->name, "no scale")
123 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 113 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
124 { 114 {
125 elm_image_no_scale_set(obj, param->i); 115 elm_image_no_scale_set(obj, param->i);
126 param_icon->no_scale = param->i;
127 return EINA_TRUE; 116 return EINA_TRUE;
128 } 117 }
129 else if (!strcmp(param->name, "scale up") 118 else if (!strcmp(param->name, "scale up")
130 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 119 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
131 { 120 {
132 elm_image_resizable_set(obj, param->i, param_icon->scale_down); 121 elm_image_resizable_get(obj, NULL, &p);
133 param_icon->scale_up = param->i; 122 elm_image_resizable_set(obj, param->i, p);
134 return EINA_TRUE; 123 return EINA_TRUE;
135 } 124 }
136 else if (!strcmp(param->name, "scale down") 125 else if (!strcmp(param->name, "scale down")
137 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 126 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
138 { 127 {
139 elm_image_resizable_set(obj, param_icon->scale_up, param->i); 128 elm_image_resizable_get(obj, &p, NULL);
140 param_icon->scale_down = param->i; 129 elm_image_resizable_set(obj, p, param->i);
141 return EINA_TRUE; 130 return EINA_TRUE;
142 } 131 }
143 else if (!strcmp(param->name, "fill outside") 132 else if (!strcmp(param->name, "fill outside")
144 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 133 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
145 { 134 {
146 elm_image_fill_outside_set(obj, param->i); 135 elm_image_fill_outside_set(obj, param->i);
147 param_icon->fill_outside = param->i;
148 return EINA_TRUE; 136 return EINA_TRUE;
149 } 137 }
150 else if (!strcmp(param->name, "prescale") 138 else if (!strcmp(param->name, "prescale")
151 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT) 139 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
152 { 140 {
153 elm_image_prescale_set(obj, param->i); 141 elm_image_prescale_set(obj, param->i);
154 param_icon->prescale_size = param->i;
155 return EINA_TRUE; 142 return EINA_TRUE;
156 } 143 }
157 else if (!strcmp(param->name, "icon")) 144 else if (!strcmp(param->name, "icon"))
@@ -183,49 +170,50 @@ external_icon_param_set(void *data EINA_UNUSED, Evas_Object *obj,
183 170
184static Eina_Bool 171static Eina_Bool
185external_icon_param_get(void *data EINA_UNUSED, 172external_icon_param_get(void *data EINA_UNUSED,
186 const Evas_Object *obj EINA_UNUSED, 173 const Evas_Object *obj,
187 Edje_External_Param *param) 174 Edje_External_Param *param)
188{ 175{
176
189 if (!strcmp(param->name, "file") 177 if (!strcmp(param->name, "file")
190 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) 178 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
191 { 179 {
192 param->s = param_icon->file; 180 elm_image_file_get(obj, &param->s, NULL);
193 return EINA_TRUE; 181 return EINA_TRUE;
194 } 182 }
195 else if (!strcmp(param->name, "smooth") 183 else if (!strcmp(param->name, "smooth")
196 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 184 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
197 { 185 {
198 param->i = param_icon->smooth; 186 param->i = elm_image_smooth_get(obj);
199 return EINA_TRUE; 187 return EINA_TRUE;
200 } 188 }
201 else if (!strcmp(param->name, "no scale") 189 else if (!strcmp(param->name, "no scale")
202 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 190 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
203 { 191 {
204 param->i = param_icon->no_scale; 192 param->i = elm_image_no_scale_get(obj);
205 return EINA_TRUE; 193 return EINA_TRUE;
206 } 194 }
207 else if (!strcmp(param->name, "scale up") 195 else if (!strcmp(param->name, "scale up")
208 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 196 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
209 { 197 {
210 param->i = param_icon->scale_up; 198 elm_image_resizable_get(obj, NULL, (Eina_Bool *)(&param->i));
211 return EINA_TRUE; 199 return EINA_TRUE;
212 } 200 }
213 else if (!strcmp(param->name, "scale down") 201 else if (!strcmp(param->name, "scale down")
214 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 202 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
215 { 203 {
216 param->i = param_icon->scale_down; 204 elm_image_resizable_get(obj, (Eina_Bool *)(&param->i), NULL);
217 return EINA_TRUE; 205 return EINA_TRUE;
218 } 206 }
219 else if (!strcmp(param->name, "fill outside") 207 else if (!strcmp(param->name, "fill outside")
220 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 208 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
221 { 209 {
222 param->i = param_icon->fill_outside; 210 param->i = elm_image_fill_outside_get(obj);
223 return EINA_TRUE; 211 return EINA_TRUE;
224 } 212 }
225 else if (!strcmp(param->name, "prescale") 213 else if (!strcmp(param->name, "prescale")
226 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT) 214 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
227 { 215 {
228 param->i = param_icon->prescale_size; 216 param->i = elm_image_prescale_get(obj);
229 return EINA_TRUE; 217 return EINA_TRUE;
230 } 218 }
231 else if (!strcmp(param->name, "icon")) 219 else if (!strcmp(param->name, "icon"))
@@ -247,9 +235,8 @@ external_icon_params_parse(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
247 Elm_Params_Icon *mem; 235 Elm_Params_Icon *mem;
248 Edje_External_Param *param; 236 Edje_External_Param *param;
249 const Eina_List *l; 237 const Eina_List *l;
250 param_icon = calloc(1, sizeof(Elm_Params_Icon));
251 mem = ELM_NEW(Elm_Params_Icon); 238 mem = ELM_NEW(Elm_Params_Icon);
252 if (!mem) 239 if (EINA_UNLIKELY(!mem))
253 return NULL; 240 return NULL;
254 241
255 EINA_LIST_FOREACH(params, l, param) 242 EINA_LIST_FOREACH(params, l, param)
@@ -312,10 +299,6 @@ external_icon_params_free(void *params)
312 if (mem->file) 299 if (mem->file)
313 eina_stringshare_del(mem->file); 300 eina_stringshare_del(mem->file);
314 301
315 if (param_icon->file)
316 eina_stringshare_del(param_icon->file);
317 free(param_icon);
318
319 if (mem->icon) 302 if (mem->icon)
320 eina_stringshare_del(mem->icon); 303 eina_stringshare_del(mem->icon);
321 free(mem); 304 free(mem);