[geary/wip/728002-webkit2: 91/96] Minor TimeoutManager optimisation.



commit a170c1ed410c6f44da5ce181bd38ce087f93cbbb
Author: Michael James Gratton <mike vee net>
Date:   Fri Jan 6 10:54:34 2017 +1100

    Minor TimeoutManager optimisation.

 src/engine/util/util-timeout-manager.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/engine/util/util-timeout-manager.vala b/src/engine/util/util-timeout-manager.vala
index 92adfdc..d8c9322 100644
--- a/src/engine/util/util-timeout-manager.vala
+++ b/src/engine/util/util-timeout-manager.vala
@@ -102,12 +102,16 @@ public class Geary.TimeoutManager : BaseObject {
     }
 
     private bool on_trigger() {
-        callback(this);
         bool ret = Source.CONTINUE;
+        // If running only once, reset the source id now in case the
+        // callback resets the timer while it is executing, so we
+        // avoid removing the source just before it would be removed
+        // after this call anyway
         if (this.repetition == Repeat.ONCE) {
             this.source_id = -1;
             ret = Source.REMOVE;
         }
+        callback(this);
         return ret;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]