summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2017-03-30 20:13:39 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2017-03-31 13:30:53 +0900
commita4d2c51d1404c1d8563dd7ac37e64ee105aa6226 (patch)
tree4e8cbab92ae14956f53f3bbfe3a3f590757c0cf2
parent36ab489a6fbb546b26bdcbc5117bb8bf6adddc0c (diff)
elm_flipselector: fixed flipselector item deletion process
flipselector item destructor had a severe drawback and this patch fixes it. when deleting multiple items at once, the view needs to be updated only once. however, the destructor updated the view on deletion of every single item and it caused a severe performance issue. the worst case happened when deleting a flipselector object - with 10000 items, it took 10 seconds to finish deletion. this patch has two points: 1. if a flipselector object is on deletion, item destructor doesn't update the view 2. otherwise, view update is handled in one job for multiple item deletion
-rw-r--r--src/lib/elementary/elm_flipselector.c73
-rw-r--r--src/lib/elementary/elm_widget_flipselector.h2
2 files changed, 47 insertions, 28 deletions
diff --git a/src/lib/elementary/elm_flipselector.c b/src/lib/elementary/elm_flipselector.c
index bae941edf0..dc14ecda88 100644
--- a/src/lib/elementary/elm_flipselector.c
+++ b/src/lib/elementary/elm_flipselector.c
@@ -253,47 +253,64 @@ _send_msg(Elm_Flipselector_Data *sd,
253 _on_item_changed(sd); 253 _on_item_changed(sd);
254} 254}
255 255
256static void
257_view_update(void *data)
258{
259 Evas_Object *obj = data;
260 ELM_FLIPSELECTOR_DATA_GET(obj, sd);
261 Elm_Object_Item *eo_item;
262
263 sd->view_update = NULL;
264 sd->need_update = EINA_FALSE;
265
266 if (sd->current)
267 {
268 eo_item = sd->current->data;
269 ELM_FLIPSELECTOR_ITEM_DATA_GET(eo_item, item);
270 _send_msg(sd, MSG_FLIP_DOWN, (char *)item->label);
271 }
272 else
273 {
274 _send_msg(sd, MSG_FLIP_DOWN, "");
275 elm_layout_signal_emit(obj, "elm,state,button,hidden", "elm");
276 }
277}
278
256EOLIAN static void 279EOLIAN static void
257_elm_flipselector_item_efl_object_destructor(Eo *eo_item, Elm_Flipselector_Item_Data *item) 280_elm_flipselector_item_efl_object_destructor(Eo *eo_item, Elm_Flipselector_Item_Data *item)
258{ 281{
259 Elm_Object_Item *eo_item2;
260 Eina_List *l; 282 Eina_List *l;
261
262 ELM_FLIPSELECTOR_DATA_GET(WIDGET(item), sd); 283 ELM_FLIPSELECTOR_DATA_GET(WIDGET(item), sd);
263 284
264 EINA_LIST_FOREACH(sd->items, l, eo_item2) 285 if (sd->deleting)
265 { 286 {
266 if (eo_item2 == eo_item) 287 eina_stringshare_del(item->label);
267 { 288 sd->items = eina_list_remove(sd->items, eo_item);
268 if (sd->current == l) 289 efl_destructor(efl_super(eo_item, ELM_FLIPSELECTOR_ITEM_CLASS));
269 { 290
270 sd->current = l->prev; 291 return;
271 if (!sd->current) sd->current = l->next;
272 if (sd->current)
273 {
274 eo_item2 = sd->current->data;
275 ELM_FLIPSELECTOR_ITEM_DATA_GET(eo_item2, item2);
276 _send_msg(sd, MSG_FLIP_DOWN, (char *)item2->label);
277 }
278 else _send_msg(sd, MSG_FLIP_DOWN, "");
279 }
280 sd->items = eina_list_remove_list(sd->items, l);
281 break;
282 }
283 } 292 }
284 293
285 if (eina_list_count(sd->items) <= 1) 294 if ((sd->current) && (sd->current->data == eo_item))
286 elm_layout_signal_emit 295 {
287 (sd->obj, "elm,state,button,hidden", "elm"); 296 sd->need_update = EINA_TRUE;
288 else 297 l = sd->current->prev;
289 elm_layout_signal_emit 298 if (!l) l = sd->current->next;
290 (sd->obj, "elm,state,button,visible", "elm"); 299 if (!l) sd->current = NULL;
300 else sd->current = l;
301 }
291 302
292 eina_stringshare_del(item->label); 303 eina_stringshare_del(item->label);
304 sd->items = eina_list_remove(sd->items, eo_item);
305 efl_destructor(efl_super(eo_item, ELM_FLIPSELECTOR_ITEM_CLASS));
306
293 _sentinel_eval(sd); 307 _sentinel_eval(sd);
294 _update_view(sd->obj);
295 308
296 efl_destructor(efl_super(eo_item, ELM_FLIPSELECTOR_ITEM_CLASS)); 309 if (sd->need_update)
310 {
311 if (sd->view_update) ecore_job_del(sd->view_update);
312 sd->view_update = ecore_job_add(_view_update, WIDGET(item));
313 }
297} 314}
298 315
299EOLIAN static Eo * 316EOLIAN static Eo *
diff --git a/src/lib/elementary/elm_widget_flipselector.h b/src/lib/elementary/elm_widget_flipselector.h
index 2e348abbc2..1fca1a623d 100644
--- a/src/lib/elementary/elm_widget_flipselector.h
+++ b/src/lib/elementary/elm_widget_flipselector.h
@@ -32,6 +32,7 @@ struct _Elm_Flipselector_Data
32 Eina_List *sentinel; /* item containing the largest 32 Eina_List *sentinel; /* item containing the largest
33 * label string */ 33 * label string */
34 Ecore_Timer *spin; 34 Ecore_Timer *spin;
35 Ecore_Job *view_update;
35 36
36 unsigned int max_len; 37 unsigned int max_len;
37 double interval, first_interval; 38 double interval, first_interval;
@@ -41,6 +42,7 @@ struct _Elm_Flipselector_Data
41 int walking; 42 int walking;
42 Eina_Bool evaluating : 1; 43 Eina_Bool evaluating : 1;
43 Eina_Bool deleting : 1; 44 Eina_Bool deleting : 1;
45 Eina_Bool need_update : 1;
44}; 46};
45 47
46typedef struct _Elm_Flipselector_Item_Data Elm_Flipselector_Item_Data; 48typedef struct _Elm_Flipselector_Item_Data Elm_Flipselector_Item_Data;