From 215a164e57c7eb19beca503be2da1f50660ffb82 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 9 May 2016 11:06:49 +0200 Subject: Ensure that timers are freed and activated when necessary --- src/common/hexchat.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/common/hexchat.c b/src/common/hexchat.c index 3104ec53..64fd351e 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -377,26 +377,50 @@ hexchat_reinit_timers (void) static int lag_check_tag = 0; static int away_tag = 0; - if (prefs.hex_notify_timeout) + /* notify timeout */ + if (prefs.hex_notify_timeout && notify_tag == 0) { notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout, notify_checklist, NULL); - } else + } + else if (notify_tag != 0) { fe_timeout_remove (notify_tag); + notify_tag = 0; } - fe_timeout_remove (away_tag); - away_tag = fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL); + /* away status tracking */ + if (prefs.hex_away_track && away_tag == 0) + { + away_tag = fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL); + } + else if (away_tag != 0) + { + fe_timeout_remove (away_tag); + away_tag = 0; + } - if (prefs.hex_gui_lagometer) + /* lag-o-meter */ + if (prefs.hex_gui_lagometer && lag_check_update_tag == 0) { lag_check_update_tag = fe_timeout_add (500, hexchat_lag_check_update, NULL); - lag_check_tag = fe_timeout_add_seconds (30, hexchat_lag_check, NULL); - } else + } + else if (lag_check_update_tag != 0) { fe_timeout_remove (lag_check_update_tag); + lag_check_update_tag = 0; + } + + /* network timeouts and lag-o-meter */ + if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer) + && lag_check_tag == 0) + { + lag_check_tag = fe_timeout_add_seconds (30, hexchat_lag_check, NULL); + } + else if (lag_check_tag != 0) + { fe_timeout_remove (lag_check_tag); + lag_check_tag = 0; } } -- cgit 1.4.1