]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - unix/gtkwin.c
It's a new year.
[PuTTY.git] / unix / gtkwin.c
index 19ada0b8d5a045151510734ca5b65c04a2e80721..4cce11e6e52b9431fab0df0423ced7c835a81605 100644 (file)
@@ -1476,7 +1476,21 @@ static gint timer_trigger(gpointer data)
     unsigned long next, then;
     long ticks;
 
-    if (run_timers(now, &next)) {
+    /*
+     * Destroy the timer we got here on.
+     */
+    if (timer_id) {
+       gtk_timeout_remove(timer_id);
+        timer_id = 0;
+    }
+
+    /*
+     * 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)
@@ -1488,8 +1502,9 @@ static gint timer_trigger(gpointer data)
     }
 
     /*
-     * Never let a timer resume. If we need another one, we've
-     * asked for it explicitly above.
+     * Returning FALSE means 'don't call this timer again', which
+     * _should_ be redundant given that we removed it above, but just
+     * in case, return FALSE anyway.
      */
     return FALSE;
 }