netstar pushed a commit to branch master. http://git.enlightenment.org/apps/evisum.git/commit/?id=eca697853df17896c2f17cba9c90d904abc08734
commit eca697853df17896c2f17cba9c90d904abc08734 Author: Alastair Poole <nets...@gmail.com> Date: Wed Mar 3 16:43:06 2021 +0000 proclist: delayed del. --- src/bin/ui/ui_cache.c | 30 ++++++++++++++++++++++++++++++ src/bin/ui/ui_cache.h | 5 +++++ src/bin/ui/ui_process_list.c | 4 +++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/bin/ui/ui_cache.c b/src/bin/ui/ui_cache.c index 4d2bd80..170709e 100644 --- a/src/bin/ui/ui_cache.c +++ b/src/bin/ui/ui_cache.c @@ -11,6 +11,8 @@ evisum_ui_item_cache_new(Evas_Object *parent, cache->item_create_cb = create_cb; cache->inactive = cache->active = NULL; cache->size = size; + cache->pending = NULL; + cache->pending_timer = NULL; for (int i = 0; i < size; i++) { @@ -61,6 +63,23 @@ evisum_ui_item_cache_steal(Evisum_Ui_Cache *cache, Eina_List *objs) } } +static Eina_Bool +_pending_triggered_cb(void *data) +{ + + Eina_List *l, *l_next; + Evas_Object *o; + Evisum_Ui_Cache *cache = data; + + EINA_LIST_FOREACH_SAFE(cache->pending, l, l_next, o) + { + cache->pending = eina_list_remove_list(cache->pending, l); + evas_object_del(o); + } + cache->pending_timer = NULL; + return 0; +} + Item_Cache * evisum_ui_item_cache_item_get(Evisum_Ui_Cache *cache) { @@ -91,10 +110,12 @@ evisum_ui_item_cache_reset(Evisum_Ui_Cache *cache) EINA_LIST_FREE(cache->active, it) { + cache->pending = eina_list_append(cache->pending, it->obj); free(it); } EINA_LIST_FREE(cache->inactive, it) { + cache->pending = eina_list_append(cache->pending, it->obj); free(it); } for (int i = 0; i < cache->size; i++) @@ -108,6 +129,13 @@ evisum_ui_item_cache_reset(Evisum_Ui_Cache *cache) } } +void +evisum_ui_item_cache_pending_del(Evisum_Ui_Cache *cache) +{ + if (!cache->pending_timer) + cache->pending_timer = ecore_timer_add(0.5, _pending_triggered_cb, cache); +} + Eina_Bool evisum_ui_item_cache_item_release(Evisum_Ui_Cache *cache, Evas_Object *obj) { @@ -153,5 +181,7 @@ evisum_ui_item_cache_free(Evisum_Ui_Cache *cache) free(it); EINA_LIST_FREE(cache->inactive, it) free(it); + eina_list_free(cache->pending); + free(cache); } diff --git a/src/bin/ui/ui_cache.h b/src/bin/ui/ui_cache.h index 5d595c2..2bdcc0d 100644 --- a/src/bin/ui/ui_cache.h +++ b/src/bin/ui/ui_cache.h @@ -3,6 +3,7 @@ #include <Eina.h> #include <Evas.h> +#include <Ecore.h> typedef struct _Evisum_Ui_Cache { Eina_List *inactive; @@ -10,6 +11,8 @@ typedef struct _Evisum_Ui_Cache { Evas_Object *parent; Evas_Object *(*item_create_cb)(Evas_Object *); int size; + Ecore_Timer *pending_timer; + Eina_List *pending; } Evisum_Ui_Cache; typedef struct _Item_Cache { @@ -34,5 +37,7 @@ evisum_ui_item_cache_reset(Evisum_Ui_Cache *cache); void evisum_ui_item_cache_steal(Evisum_Ui_Cache *cache, Eina_List *objs); +void +evisum_ui_item_cache_pending_del(Evisum_Ui_Cache *cache); #endif diff --git a/src/bin/ui/ui_process_list.c b/src/bin/ui/ui_process_list.c index 8639870..fc4fb4e 100644 --- a/src/bin/ui/ui_process_list.c +++ b/src/bin/ui/ui_process_list.c @@ -176,9 +176,9 @@ _content_reset(Ui_Data *pd) } elm_table_pack(pd->tb_content, pd->glist, 0, 1, j, 1); elm_table_pack(pd->tb_content, pd->summary.fr, 0, 2, j, 1); + elm_genlist_clear(pd->glist); if (pd->cache) evisum_ui_item_cache_reset(pd->cache); - elm_genlist_clear(pd->glist); } static void @@ -991,6 +991,7 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, if (!pd->poll_count) ecore_timer_add(1.0, _bring_in, pd); pd->poll_count++; + } static void @@ -1020,6 +1021,7 @@ _btn_clicked_state_save(Ui_Data *pd, Evas_Object *btn) if (pd->fields_menu) { + evisum_ui_item_cache_pending_del(pd->cache); evas_object_del(pd->fields_menu); pd->fields_menu = NULL; return; --