ShellAppSystem: own the memory for the startup wm class and app id

The hash table must keep a copy of the IDs, because the GAppInfos
are unreferenced (and thus freed) at the end of the function.
This was possibly not a problem if the GAppInfos were referencing
the memory-mapped cache, but it becomes one for regularly parsed
desktop files in ~/.local.

https://bugzilla.gnome.org/show_bug.cgi?id=721039
This commit is contained in:
Giovanni Campagna 2013-12-25 20:35:13 +01:00
parent 114d8d0aba
commit f3feb13dfe

View File

@ -87,8 +87,13 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
id = g_app_info_get_id (info);
startup_wm_class = g_desktop_app_info_get_startup_wm_class (G_DESKTOP_APP_INFO (info));
if (startup_wm_class != NULL)
g_hash_table_insert (priv->startup_wm_class_to_id, (char *) startup_wm_class, (char *) id);
{
g_hash_table_insert (priv->startup_wm_class_to_id,
g_strdup (startup_wm_class), g_strdup (id));
g_debug ("Application %s has StartupWMClass %s", id, startup_wm_class);
}
}
g_list_free_full (apps, g_object_unref);
@ -120,7 +125,7 @@ shell_app_system_init (ShellAppSystem *self)
NULL,
(GDestroyNotify)g_object_unref);
priv->startup_wm_class_to_id = g_hash_table_new (g_str_hash, g_str_equal);
priv->startup_wm_class_to_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
monitor = g_app_info_monitor_get ();
g_signal_connect (monitor, "changed", G_CALLBACK (installed_changed), self);