Commit 054d7a32 authored by Kalev Lember's avatar Kalev Lember
Browse files

app list: Don't filter out apps with NULL app ID

These are valid when e.g. installing local rpms, or when processing a
org.freedesktop.PackageKit dbus session service request to install a
package that has no appdata.
parent 5fcf4144
......@@ -400,14 +400,18 @@ gs_app_list_filter_duplicates (GsAppList *list, GsAppListFilterFlags flags)
const gchar *id;
g_autoptr(GHashTable) hash = NULL;
g_autoptr(GList) values = NULL;
g_autoptr(GPtrArray) apps_no_id = NULL;
GList *l;
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&list->mutex);
g_return_if_fail (GS_IS_APP_LIST (list));
/* create a new list with just the unique items */
/* a hash table to hold apps with unique app ids */
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_object_unref);
/* an array to hold apps that have NULL app ids */
apps_no_id = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
for (i = 0; i < list->array->len; i++) {
app = gs_app_list_index (list, i);
id = gs_app_get_unique_id (app);
......@@ -415,7 +419,8 @@ gs_app_list_filter_duplicates (GsAppList *list, GsAppListFilterFlags flags)
id = gs_app_get_id (app);
if (id == NULL) {
g_autofree gchar *str = gs_app_to_string (app);
g_debug ("ignoring as no application id for: %s", str);
g_debug ("adding without deduplication as no app id: %s", str);
g_ptr_array_add (apps_no_id, g_object_ref (app));
found = g_hash_table_lookup (hash, id);
......@@ -457,6 +462,12 @@ gs_app_list_filter_duplicates (GsAppList *list, GsAppListFilterFlags flags)
app = GS_APP (l->data);
gs_app_list_add_safe (list, app);
/* add back apps with NULL app ids to the existing list */
for (i = 0; i < apps_no_id->len; i++) {
app = g_ptr_array_index (apps_no_id, i);
gs_app_list_add_safe (list, app);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment