Commits

jjacky committed 725892c

When buttons for Upgrades & AUR were both used/clicked at the same time, kalu would run a check after each, fixed; Closes #8

Usually when kalu is busy nothing else to get it busy can be started. One exception is starting Upgrades & AUR from notification buttons. In such a case, when the first one is done, kalu would run a check (to refresh) then do it again after the second one.
And using kalu's updater its state could go back to not busy even though it or the other process is still running, possibly leading to more trouble.
kalu will now wait for both to be done to go back to be non-busy & do whatever needs to be done.

  • Participants
  • Parent commits 1eef8ff

Comments (0)

Files changed (2)

 } kalu_package_t;
 
 typedef struct _kalpm_state_t {
-    gboolean    is_busy;
+    gint        is_busy;
     guint       timeout;
     guint       timeout_icon;
     GDateTime  *last_check;
 static void icon_popup_cb (GtkStatusIcon *icon, guint button, guint activate_time, gpointer data);
 static void free_config (void);
 
-static kalpm_state_t kalpm_state = { FALSE, 0, 0, NULL, 0, 0, 0, 0, 0, 0 };
+static kalpm_state_t kalpm_state = { 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0 };
 
 static gboolean
 show_error_cmdline (gchar *arg[])
 void
 set_kalpm_busy (gboolean busy)
 {
-    if (busy == kalpm_state.is_busy)
+    gint old = kalpm_state.is_busy;
+    
+    /* we use an counter because when using a cmdline for both upgrades & AUR,
+     * and both are triggered at the same time (from notifications) then we
+     * should only bo back to not busy when *both* are done; fixes #8 */
+    if (busy)
+    {
+        ++kalpm_state.is_busy;
+    }
+    else if (kalpm_state.is_busy > 0)
+    {
+        --kalpm_state.is_busy;
+    }
+    
+    /* make sure the state changed/there's something to do */
+    if ((old > 0  && kalpm_state.is_busy > 0)
+     || (old == 0 && kalpm_state.is_busy == 0))
     {
         return;
     }
         /* set timeout for status icon */
         kalpm_state.timeout_icon = g_timeout_add (420,
             (GSourceFunc) switch_status_icon, NULL);
-        
-        kalpm_state.is_busy = TRUE;
     }
     else
     {
             /* ensure icon is right */
             set_kalpm_nb (0, 0);
         }
-        
-        kalpm_state.is_busy = FALSE;
     }
 }