From 35a359af97edb8d460132c484d9f24916ee1c456 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Thu, 24 Dec 2020 10:16:19 +0000 Subject: [PATCH] handlers: clean up --- src/bin/evisum_server.c | 26 ++++++++++++++++++-------- src/bin/main.c | 3 ++- src/bin/ui/ui.h | 3 ++- src/bin/ui/ui_memory.c | 13 ------------- src/bin/ui/ui_process_list.c | 2 +- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/bin/evisum_server.c b/src/bin/evisum_server.c index 0f3e1cd..afbed15 100644 --- a/src/bin/evisum_server.c +++ b/src/bin/evisum_server.c @@ -68,10 +68,10 @@ evisum_server_init(void *data) } typedef struct _Evisum_Server_Client { - Ecore_Con_Server *srv; - Evisum_Action action; - int pid; - Eina_Bool success; + Ecore_Con_Server *srv; + Evisum_Action action; + int pid; + Eina_Bool success; } Evisum_Server_Client; static Eina_Bool @@ -131,6 +131,7 @@ Eina_Bool evisum_server_client_add(Evisum_Action action, int pid) { Evisum_Server_Client *client; + Ecore_Event_Handler *handler[4]; Eina_Bool ok; Ecore_Con_Server *srv = ecore_con_server_connect(ECORE_CON_LOCAL_USER, LISTEN_SOCKET_NAME, 0, NULL); @@ -144,13 +145,22 @@ evisum_server_client_add(Evisum_Action action, int pid) client->pid = pid; client->srv = srv; - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _evisum_server_client_connect_cb, client); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _evisum_server_client_done_cb, client); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, _evisum_server_client_done_cb, client); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _evisum_server_client_data_cb, client); + handler[0] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, + _evisum_server_client_connect_cb, client); + handler[1] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, + _evisum_server_client_done_cb, client); + handler[2] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, + _evisum_server_client_done_cb, client); + handler[3] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, + _evisum_server_client_data_cb, client); ecore_main_loop_begin(); + ecore_event_handler_del(handler[0]); + ecore_event_handler_del(handler[1]); + ecore_event_handler_del(handler[2]); + ecore_event_handler_del(handler[3]); + ok = client->success; free(client); diff --git a/src/bin/main.c b/src/bin/main.c index a78fd59..88c2f6c 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -26,7 +26,7 @@ _shutdown_cb(void *data, int type, void *event EINA_UNUSED) static void _signals(Ui *ui) { - ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _shutdown_cb, ui); + ui->handler_sig = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _shutdown_cb, ui); } int @@ -86,6 +86,7 @@ main(int argc, char **argv) ecore_main_loop_begin(); + ecore_event_handler_del(ui->handler_sig); evisum_ui_shutdown(ui); evisum_server_shutdown(); diff --git a/src/bin/ui/ui.h b/src/bin/ui/ui.h index 90b2775..e255d17 100644 --- a/src/bin/ui/ui.h +++ b/src/bin/ui/ui.h @@ -18,7 +18,8 @@ typedef struct Ui { - pid_t program_pid; + pid_t program_pid; + Ecore_Event_Handler *handler_sig; struct { diff --git a/src/bin/ui/ui_memory.c b/src/bin/ui/ui_memory.c index 9bee0a9..1b901bf 100644 --- a/src/bin/ui/ui_memory.c +++ b/src/bin/ui/ui_memory.c @@ -341,14 +341,6 @@ _graph_guide(Evas_Object *parent, int r, int g, int b, int a) return btn; } -static Eina_Bool -_elm_config_changed_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED) -{ - Ui_Data *pd = data; - - return EINA_TRUE; -} - static void _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) @@ -503,11 +495,6 @@ ui_win_memory_add(Ui *ui) else elm_win_center(win, 1, 1); - _elm_config_changed_cb(pd, 0, NULL); - - ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED, - _elm_config_changed_cb, pd); - evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd); evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd); evas_object_show(win); diff --git a/src/bin/ui/ui_process_list.c b/src/bin/ui/ui_process_list.c index c4adbfe..a368989 100644 --- a/src/bin/ui/ui_process_list.c +++ b/src/bin/ui/ui_process_list.c @@ -13,7 +13,7 @@ extern Evisum_Config *_evisum_config; extern int EVISUM_EVENT_CONFIG_CHANGED; -Eina_Lock _lock; +static Eina_Lock _lock; typedef struct {