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
This commit is contained in:
Milan Bouchet-Valat 2009-05-11 20:52:33 +02:00 committed by Owen W. Taylor
parent 675fe56176
commit bea595d143

View File

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