summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-09-17 00:07:53 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-09-17 00:07:53 +0100
commitac70f6ce267d5b68b94b6abb2564e55394d38f6c (patch)
treedd8b793cdc37f346bc698b7b868e969fad314bbe
parent4cd3bb45c4a41a6af698dfae743b3039586ba075 (diff)
tasks - handle shutdown case with still existing clients in list
avoid accessing possibly freed/deleted clients in the case of a clean shutdown if clients still exist. @fix
-rw-r--r--src/modules/tasks/e_mod_main.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/modules/tasks/e_mod_main.c b/src/modules/tasks/e_mod_main.c
index acb3f670c..b99469d06 100644
--- a/src/modules/tasks/e_mod_main.c
+++ b/src/modules/tasks/e_mod_main.c
@@ -386,6 +386,26 @@ _tasks_cb_iconify_provider(void *data, Evas_Object *obj, const char *signal)
386 return EINA_FALSE; 386 return EINA_FALSE;
387} 387}
388 388
389static void
390_taks_client_remove(E_Client *ec)
391{
392 Tasks *tasks;
393 Eina_List *l;
394
395 if (!tasks_config) return;
396 EINA_LIST_FOREACH(tasks_config->tasks, l, tasks)
397 {
398 tasks->clients = eina_list_remove(tasks->clients, ec);
399 }
400 _tasks_refill_all();
401}
402
403static void
404_tasks_cb_client_del(void *data EINA_UNUSED, void *obj)
405{
406 _taks_client_remove(obj);
407}
408
389static Tasks * 409static Tasks *
390_tasks_new(Evas *e, E_Zone *zone, const char *id) 410_tasks_new(Evas *e, E_Zone *zone, const char *id)
391{ 411{
@@ -403,7 +423,10 @@ _tasks_new(Evas *e, E_Zone *zone, const char *id)
403 { 423 {
404 if ((!e_client_util_ignored_get(ec)) && (!e_object_is_del(E_OBJECT(ec))) && 424 if ((!e_client_util_ignored_get(ec)) && (!e_object_is_del(E_OBJECT(ec))) &&
405 (!e_client_util_is_popup(ec))) 425 (!e_client_util_is_popup(ec)))
406 tasks->clients = eina_list_append(tasks->clients, ec); 426 {
427 e_object_delfn_add(E_OBJECT(ec), _tasks_cb_client_del, NULL);
428 tasks->clients = eina_list_append(tasks->clients, ec);
429 }
407 } 430 }
408 431
409 elm_box_homogeneous_set(tasks->o_items, 1); 432 elm_box_homogeneous_set(tasks->o_items, 1);
@@ -421,7 +444,7 @@ _tasks_free(Tasks *tasks)
421 e_comp_object_effect_mover_del(tasks->iconify_provider); 444 e_comp_object_effect_mover_del(tasks->iconify_provider);
422 EINA_LIST_FREE(tasks->items, item) 445 EINA_LIST_FREE(tasks->items, item)
423 _tasks_item_free(item); 446 _tasks_item_free(item);
424 eina_list_free(tasks->clients); 447 tasks->clients = eina_list_free(tasks->clients);
425 evas_object_del(tasks->o_items); 448 evas_object_del(tasks->o_items);
426 free(tasks); 449 free(tasks);
427} 450}
@@ -1178,7 +1201,10 @@ _tasks_cb_event_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
1178 EINA_LIST_FOREACH(tasks_config->tasks, l, tasks) 1201 EINA_LIST_FOREACH(tasks_config->tasks, l, tasks)
1179 { 1202 {
1180 if ((!tasks->clients) || (!eina_list_data_find(tasks->clients, ev->ec))) 1203 if ((!tasks->clients) || (!eina_list_data_find(tasks->clients, ev->ec)))
1181 tasks->clients = eina_list_append(tasks->clients, ev->ec); 1204 {
1205 e_object_delfn_add(E_OBJECT(ev->ec), _tasks_cb_client_del, NULL);
1206 tasks->clients = eina_list_append(tasks->clients, ev->ec);
1207 }
1182 } 1208 }
1183 _tasks_refill_all(); 1209 _tasks_refill_all();
1184 return EINA_TRUE; 1210 return EINA_TRUE;
@@ -1188,14 +1214,8 @@ static Eina_Bool
1188_tasks_cb_event_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 1214_tasks_cb_event_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
1189{ 1215{
1190 E_Event_Client *ev = event; 1216 E_Event_Client *ev = event;
1191 Tasks *tasks;
1192 Eina_List *l;
1193 1217
1194 EINA_LIST_FOREACH(tasks_config->tasks, l, tasks) 1218 _taks_client_remove(ev->ec);
1195 {
1196 tasks->clients = eina_list_remove(tasks->clients, ev->ec);
1197 }
1198 _tasks_refill_all();
1199 return EINA_TRUE; 1219 return EINA_TRUE;
1200} 1220}
1201 1221