[gnome-shell] ShellAppSystem: own the memory for the startup wm class and app id



commit f3feb13dfe1a154b189d3efa8947306c5f0f1de1
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Dec 25 20:35:13 2013 +0100

    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

 src/shell-app-system.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 3a31709..db31fcb 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -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);


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