From 2138971d557147068566e9542a397661b2c23169 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Sun, 26 Oct 2014 19:05:14 +0100 Subject: Fix removing GSources On exiting the panel, xfce4-netload-plugin prints the following CRITICAL GLib: GLib-CRITICAL **: Source ID xxx was not found when attempting to remove it This patch makes it check to see if a GSource exists before destroying it, since any GSource may be destroyed early in the main event loop if its dispatch callback returns FALSE. --- panel-plugin/sensors-plugin.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c index fd64c06..ff6598e 100644 --- a/panel-plugin/sensors-plugin.c +++ b/panel-plugin/sensors-plugin.c @@ -56,6 +56,20 @@ static void +remove_gsource (guint id) +{ + if (id) { + GSource *source; + + source = g_main_context_find_source_by_id (NULL, id); + if (source) { + g_source_destroy (source); + id = 0; + } + } +} + +static void sensors_set_bar_size (GtkWidget *bar, int size, int orientation) { //TRACE ("enters sensors_set_bar_size"); @@ -1045,11 +1059,10 @@ sensors_free (XfcePanelPlugin *plugin, t_sensors *sensors) sensor_interface_cleanup(); /* remove timeout functions */ - if (sensors->timeout_id) - g_source_remove (sensors->timeout_id); + remove_gsource (sensors->timeout_id); /* double-click improvement */ - g_source_remove (sensors->doubleclick_id); + remove_gsource (sensors->doubleclick_id); /* free structures and arrays */ g_ptr_array_foreach (sensors->chips, free_chip, NULL); @@ -1332,7 +1345,8 @@ adjustment_value_changed (GtkWidget *widget, t_sensors_dialog* sd) (gint) gtk_adjustment_get_value ( GTK_ADJUSTMENT (widget) ); /* stop the timeout functions ... */ - g_source_remove (sd->sensors->timeout_id); + remove_gsource (sd->sensors->timeout_id); + /* ... and start them again */ sd->sensors->timeout_id = g_timeout_add ( sd->sensors->sensors_refresh_time * 1000, -- 2.1.2