From bc8de8a331a035deb8623911ba01c6ec800c1dc5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 13 Jul 2014 07:49:29 +0000 Subject: [PATCH] Another fix to timer handling. Robert de Bath points out that failure to remove the timer whose callback returned FALSE may not have been the cause of runaway timer explosion; another possibility is that a function called from timer_trigger()'s call to run_timers() has already set a timer up by the time run_timers() returns, and then we set another one up on top of it. Fix that too. [originally from svn r10206] --- unix/gtkwin.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index fe597bf2..4cce11e6 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -1477,15 +1477,20 @@ static gint timer_trigger(gpointer data) long ticks; /* - * Remove the timer we got here on; if we need another one, we'll - * set it up below. + * Destroy the timer we got here on. */ if (timer_id) { gtk_timeout_remove(timer_id); timer_id = 0; } - if (run_timers(now, &next)) { + /* + * run_timers() may cause a call to timer_change_notify, in which + * case a new timer will already have been set up and left in + * timer_id. If it hasn't, and run_timers reports that some timing + * still needs to be done, we do it ourselves. + */ + if (run_timers(now, &next) && !timer_id) { then = now; now = GETTICKCOUNT(); if (now - then > next - then) -- 2.45.2