Shutdown properly.

Ask threads to terminate and shutdown EFL properly.
This commit is contained in:
Alastair Poole 2018-06-16 15:09:10 +01:00
parent 8efee813e0
commit a8826641d0
3 changed files with 19 additions and 9 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;