diff --git a/src/main.c b/src/main.c index e06fc72..9c92f9d 100644 --- a/src/main.c +++ b/src/main.c @@ -50,9 +50,9 @@ main(int argc, char **argv) ecore_main_loop_begin(); - eina_shutdown(); - ecore_shutdown(); elm_shutdown(); + ecore_shutdown(); + eina_shutdown(); return 0; } diff --git a/src/ui.c b/src/ui.c index ee5f2b5..3a1b1d1 100644 --- a/src/ui.c +++ b/src/ui.c @@ -53,12 +53,12 @@ _system_stats_thread_feedback_cb(void *data, Ecore_Thread *thread, void *msg) double cpu_usage = 0.0; int i; - if (ecore_thread_check(thread)) - return; - ui = data; results = msg; + if (ecore_thread_check(thread)) + goto out; + _cpu_view_update(ui, results); _memory_view_update(ui, results); _disk_view_update(ui); @@ -79,6 +79,7 @@ _system_stats_thread_feedback_cb(void *data, Ecore_Thread *thread, void *msg) elm_progressbar_value_set(ui->progress_cpu, (double) cpu_usage / 100); elm_progressbar_value_set(ui->progress_mem, (double)((results->memory.total / 100.0) * results->memory.used) / 1000000); +out: free(results->cores); free(results); } @@ -556,9 +557,15 @@ _btn_state_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info static void _btn_quit_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - ecore_main_loop_quit(); + Ui *ui = data; - elm_exit(); + ecore_thread_cancel(ui->thread_system); + ecore_thread_cancel(ui->thread_process); + + ecore_thread_wait(ui->thread_system, 1.0); + ecore_thread_wait(ui->thread_process, 1.0); + + ecore_main_loop_quit(); } static void @@ -2120,7 +2127,7 @@ ui_add(Evas_Object *parent) _disk_view_update(ui); _process_panel_update(ui); - ecore_thread_feedback_run(_system_stats_thread, _system_stats_thread_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE); - ecore_thread_feedback_run(_system_process_list, _system_process_list_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE); + ui->thread_system = ecore_thread_feedback_run(_system_stats_thread, _system_stats_thread_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE); + ui->thread_process = ecore_thread_feedback_run(_system_process_list, _system_process_list_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE); } diff --git a/src/ui.h b/src/ui.h index 02fe95e..1c8ac6b 100644 --- a/src/ui.h +++ b/src/ui.h @@ -95,6 +95,9 @@ typedef struct Ui Evas_Object *entry_pid_state; Evas_Object *entry_pid_cpu_usage; + Ecore_Thread *thread_system; + Ecore_Thread *thread_process; + Ecore_Timer *timer_pid; pid_t selected_pid; pid_t program_pid;