From: Jean-Philippe Orsini Date: Sat, 23 Aug 2014 11:00:10 +0000 (+0200) Subject: use pthread instead of g_thread to avoid the nightmare of glib deprecating/remoring... X-Git-Tag: v1.1.1~10 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=ef58c80b895ef11c611e1865cb5ceeff9ce096d5 use pthread instead of g_thread to avoid the nightmare of glib deprecating/remoring often functions. --- diff --git a/src/main.c b/src/main.c index db4353d..811893c 100644 --- a/src/main.c +++ b/src/main.c @@ -136,12 +136,14 @@ update_psensor_values_size(struct psensor **sensors, struct config *cfg) } } -static void update_measures(struct ui_psensor *ui) +static void *update_measures(void *data) { struct psensor **sensors; struct config *cfg; int period; + struct ui_psensor *ui; + ui = (struct ui_psensor *)data; cfg = ui->config; while (1) { @@ -149,7 +151,7 @@ static void update_measures(struct ui_psensor *ui) sensors = ui->sensors; if (!sensors) - return; + pthread_exit(NULL); update_psensor_values_size(sensors, cfg); @@ -474,9 +476,8 @@ static struct psensor **create_sensors_list(const char *url, int main(int argc, char **argv) { struct ui_psensor ui; - GError *error; - GThread *thread; - int optc, cmdok, opti, use_libatasmart, new_instance; + pthread_t thread; + int optc, cmdok, opti, use_libatasmart, new_instance, ret; char *url = NULL; GApplication *app; @@ -590,11 +591,10 @@ int main(int argc, char **argv) ui_enable_alpha_channel(&ui); - thread = g_thread_create((GThreadFunc) update_measures, - &ui, TRUE, &error); + ret = pthread_create(&thread, NULL, update_measures, &ui); - if (!thread) - g_error_free(error); + if (!ret) + log_err(_("Failed to create thread for monitoring sensors")); ui.graph_update_interval = ui.config->graph_update_interval;