]> granicus.if.org Git - neomutt/commitdiff
fix refresh -- time overflowed short
authorRichard Russon <rich@flatcap.org>
Thu, 10 Dec 2015 16:58:40 +0000 (16:58 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 6 Mar 2016 00:44:21 +0000 (00:44 +0000)
rename SidebarLastRefresh to LastRefresh as it's only used in sidebar.c

buffy.c
globals.h
sidebar.c

diff --git a/buffy.c b/buffy.c
index 1d4ad4272a19b81ead0347dc444333d63a29452e..cd1233c434143534e7b9912e8971ddcf2b77e2ac 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -640,6 +640,9 @@ int mutt_buffy_check (int force)
     contex_sb.st_ino=0;
   }
   
+#ifdef USE_SIDEBAR
+  int should_refresh = sb_should_refresh();
+#endif
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
     if (tmp->magic != M_IMAP)
@@ -674,10 +677,8 @@ int mutt_buffy_check (int force)
       case M_MBOX:
       case M_MMDF:
 #ifdef USE_SIDEBAR
-       if (sb_should_refresh()) {
+       if (should_refresh)
          buffy_mbox_update (tmp, &sb);
-         sb_set_update_time();
-       }
 #endif
        if (buffy_mbox_hasnew (tmp, &sb) > 0)
          BuffyCount++;
@@ -685,10 +686,8 @@ int mutt_buffy_check (int force)
 
       case M_MAILDIR:
 #ifdef USE_SIDEBAR
-       if (sb_should_refresh()) {
+       if (should_refresh)
          buffy_maildir_update (tmp);
-         sb_set_update_time();
-       }
 #endif
        if (buffy_maildir_hasnew (tmp) > 0)
          BuffyCount++;
@@ -715,6 +714,10 @@ int mutt_buffy_check (int force)
     else if (!tmp->notified)
       BuffyNotify++;
   }
+#ifdef USE_SIDEBAR
+  if (should_refresh)
+         sb_set_update_time();
+#endif
 
   BuffyDoneTime = BuffyTime;
   return (BuffyCount);
index 9d50a514297013cc9eb224c7bafad99d0b67f855..9c87cbae9355e76f52f15ce83cd93af772da3725 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -224,7 +224,6 @@ WHERE short ScoreThresholdFlag;
 WHERE short SidebarWidth;
 #ifdef USE_SIDEBAR
 WHERE struct buffy_t *CurBuffy INITVAL(0);
-WHERE short SidebarLastRefresh;
 WHERE short SidebarRefresh;
 WHERE LIST *SidebarWhitelist INITVAL(0);
 #endif
index bb1cbf9f6e97450e2523632db952f4270aa898c1..fefc2a12bdc1c9c111f43f44701d6187b788673b 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -29,6 +29,7 @@
 
 static BUFFY *TopBuffy;
 static BUFFY *BottomBuffy;
+static time_t LastRefresh;
 static int    known_lines;
 
 /**
@@ -341,7 +342,7 @@ sb_draw (void)
                saveSidebarWidth = SidebarWidth;
                if (!option (OPTSIDEBAR))
                        SidebarWidth = 0;
-               SidebarLastRefresh = time (NULL);
+               LastRefresh = time (NULL);
                initialized = true;
        }
 
@@ -530,12 +531,15 @@ sb_draw (void)
 int
 sb_should_refresh (void)
 {
-       if (option (OPTSIDEBAR) && (SidebarRefresh > 0)) {
-               if ((time (NULL) - SidebarLastRefresh) >= SidebarRefresh) {
-                       return 1;
-               }
-       }
-       return 0;
+       if (!option (OPTSIDEBAR))
+               return 0;
+
+       if (SidebarRefresh == 0)
+               return 0;
+
+       time_t diff = (time (NULL) - LastRefresh);
+
+       return (diff >= SidebarRefresh);
 }
 
 /**
@@ -677,6 +681,6 @@ sb_set_update_time (void)
 {
        /* XXX - should this be public? */
 
-       SidebarLastRefresh = time (NULL);
+       LastRefresh = time (NULL);
 }