diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c index 95811df..96b949f 100644 --- a/panel-plugin/netload.c +++ b/panel-plugin/netload.c @@ -143,6 +143,21 @@ typedef struct } t_global_monitor; +static remove_gsource(t_global_monitor *global) +{ + if (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; + } + } +} + /* ---------------------------------------------------------------------------------------------- */ static gboolean update_monitors(t_global_monitor *global) { @@ -271,11 +286,7 @@ static gboolean update_monitors(t_global_monitor *global) /* ---------------------------------------------------------------------------------------------- */ static void run_update (t_global_monitor *global) { - if (global->timeout_id > 0) - { - g_source_remove(global->timeout_id); - global->timeout_id = 0; - } + remove_gsource(global); if (global->monitor->options.update_interval > 0) { @@ -328,10 +339,7 @@ static void monitor_set_mode (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, PRINT_DBG("monitor_set_mode"); - if (global->timeout_id) - { - g_source_remove(global->timeout_id); - } + remove_gsource(global); if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR) { @@ -389,10 +397,7 @@ static gboolean tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboard, /* ---------------------------------------------------------------------------------------------- */ static void monitor_free(XfcePanelPlugin *plugin, t_global_monitor *global) { - if (global->timeout_id) - { - g_source_remove(global->timeout_id); - } + remove_gsource(global); if (global->monitor->options.label_text) { @@ -494,8 +499,7 @@ static void setup_monitor(t_global_monitor *global, gboolean supress_warnings) { gint i; - if (global->timeout_id) - g_source_remove(global->timeout_id); + remove_gsource(global); /* Show title label? */ if (global->monitor->options.use_label)