[gnome-shell] Fix occasional crash in lists handling in ShellAppMonitor



commit bea595d14391259bbabbac9285d612c19bed3a34
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon May 11 20:52:33 2009 +0200

    Fix occasional crash in lists handling in ShellAppMonitor
    
    We need to reset the popularity GSList* at start, and everytime we load data about a another activity. This also implies fixing the typo about (activity != -1).
    
    Thanks to Dan Winship. http://bugzilla.gnome.org/show_bug.cgi?id=582215
---
 src/shell-app-monitor.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c
index 8269f58..d9f487d 100644
--- a/src/shell-app-monitor.c
+++ b/src/shell-app-monitor.c
@@ -889,7 +889,7 @@ static void
 restore_from_file (ShellAppMonitor *monitor)
 {
   int activity = -1; /* Means invalid ID */
-  GSList *popularity;
+  GSList *popularity = NULL;
   AppPopularity *app_popularity;
   GFileInputStream *input;
   GDataInputStream *data_input;
@@ -927,6 +927,7 @@ restore_from_file (ShellAppMonitor *monitor)
                   popularity = g_slist_sort (popularity, popularity_sort_apps);
                   g_hash_table_replace (monitor->popularities,
                                         GINT_TO_POINTER (activity), popularity);
+                  popularity = NULL;
                 }
               activity = atoi (line);
               /* FIXME: do something if conversion fails! */
@@ -942,7 +943,7 @@ restore_from_file (ShellAppMonitor *monitor)
         }
       /* Line is about an app.
        * If no activity was provided yet, just skip */
-      else if ((activity != 1) && (strcmp (line, "") != 0))
+      else if ((activity != -1) && (strcmp (line, "") != 0))
         {
           info = g_strsplit (line, ",", 0);
           if (info[0] && info [1] && info[2]) /* Skip on wrong syntax */



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