app-system: Filter out stale apps from cache
Since rebasing our AppSystem on GLib's facilities, we only ever append to the id-to-app cache. So if an application is uninstalled, shell_app_system_lookup_app() will still happily return it if it was cached previously. For instance if a favorite app is uninstalled, it keeps lurking in the dash until a restart. To fix, filter out removed apps from the cache when handling GAppInfoMonitor::installed-changed. https://bugzilla.gnome.org/show_bug.cgi?id=726414
This commit is contained in:
parent
e70fd5a57a
commit
66b71a36ce
@ -96,6 +96,32 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
|
||||
g_list_free_full (apps, g_object_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
app_is_stale (ShellApp *app)
|
||||
{
|
||||
GDesktopAppInfo *info;
|
||||
gboolean is_stale;
|
||||
|
||||
if (shell_app_is_window_backed (app))
|
||||
return FALSE;
|
||||
|
||||
info = g_desktop_app_info_new (shell_app_get_id (app));
|
||||
is_stale = (info == NULL);
|
||||
|
||||
if (info)
|
||||
g_object_unref (info);
|
||||
|
||||
return is_stale;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
stale_app_remove_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
return app_is_stale (value);
|
||||
}
|
||||
|
||||
static void
|
||||
installed_changed (GAppInfoMonitor *monitor,
|
||||
gpointer user_data)
|
||||
@ -104,6 +130,8 @@ installed_changed (GAppInfoMonitor *monitor,
|
||||
|
||||
scan_startup_wm_class_to_id (self);
|
||||
|
||||
g_hash_table_foreach_remove (self->priv->id_to_app, stale_app_remove_func, NULL);
|
||||
|
||||
g_signal_emit (self, signals[INSTALLED_CHANGED], 0, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user