From a84fe9a5a13301ae0bc4c618ccd7b6455e11e413 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Sat, 25 Oct 2014 21:54:34 +0200 Subject: Fix removing GSources On startup, xfce4-netload-plugin spills out the following CRITICAL GLib: GLib-CRITICAL **: Source ID 5 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/netload.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c index 95811df..ea370ff 100644 --- a/panel-plugin/netload.c +++ b/panel-plugin/netload.c @@ -271,10 +271,16 @@ static gboolean update_monitors(t_global_monitor *global) /* ---------------------------------------------------------------------------------------------- */ static void run_update (t_global_monitor *global) { - if (global->timeout_id > 0) + if (global->timeout_id) { - g_source_remove(global->timeout_id); - global->timeout_id = 0; + GSource *source; + + source = g_main_context_find_source_by_id(NULL, global->timeout_id); + if (source) + { + g_source_destroy(source); + global->timeout_id = 0; + } } if (global->monitor->options.update_interval > 0) @@ -330,7 +336,14 @@ static void monitor_set_mode (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, if (global->timeout_id) { - g_source_remove(global->timeout_id); + GSource *source; + + source = g_main_context_find_source_by_id(NULL, global->timeout_id); + if (source) + { + g_source_destroy(source); + global->timeout_id = 0; + } } if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR) @@ -391,7 +404,14 @@ static void monitor_free(XfcePanelPlugin *plugin, t_global_monitor *global) { if (global->timeout_id) { - g_source_remove(global->timeout_id); + GSource *source; + + source = g_main_context_find_source_by_id(NULL, global->timeout_id); + if (source) + { + g_source_destroy(source); + global->timeout_id = 0; + } } if (global->monitor->options.label_text) @@ -495,7 +515,16 @@ static void setup_monitor(t_global_monitor *global, gboolean supress_warnings) gint i; if (global->timeout_id) - g_source_remove(global->timeout_id); + { + GSource *source; + + source = g_main_context_find_source_by_id(NULL, global->timeout_id); + if (source) + { + g_source_destroy(source); + global->timeout_id = 0; + } + } /* Show title label? */ if (global->monitor->options.use_label) -- 2.1.2