[gnome-software] Copy the GsApp id when using the app cache



commit 31ae2f31850075c3c805938ce65caba2170b6725
Author: Richard Hughes <richard hughsie com>
Date:   Tue Oct 8 10:49:06 2013 +0100

    Copy the GsApp id when using the app cache
    
    The GsApp originally backing that data might get removed later.

 src/gs-plugin-loader.c |    8 ++++----
 src/gs-plugin.c        |    3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 01267bc..9c38332 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -138,7 +138,7 @@ gs_plugin_loader_dedupe (GsPluginLoader *plugin_loader, GsApp *app)
 
        /* insert new entry */
        g_hash_table_insert (priv->app_cache,
-                            (gpointer) gs_app_get_id (app),
+                            g_strdup (gs_app_get_id (app)),
                             g_object_ref (app));
 
        /* no ref */
@@ -2181,9 +2181,9 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
        plugin_loader->priv->pending_apps = g_ptr_array_new_with_free_func ((GFreeFunc) g_object_unref);
        plugin_loader->priv->profile = gs_profile_new ();
        plugin_loader->priv->app_cache = g_hash_table_new_full (g_str_hash,
-                                                                g_str_equal,
-                                                                NULL,
-                                                                (GFreeFunc) g_object_unref);
+                                                               g_str_equal,
+                                                               g_free,
+                                                               (GFreeFunc) g_object_unref);
 
        g_mutex_init (&plugin_loader->priv->pending_apps_mutex);
        g_mutex_init (&plugin_loader->priv->app_cache_mutex);
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 588f4fb..c30e6b2 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -50,6 +50,8 @@ gs_plugin_status_to_string (GsPluginStatus status)
 void
 gs_plugin_add_app (GList **list, GsApp *app)
 {
+       g_return_if_fail (list != NULL);
+       g_return_if_fail (GS_IS_APP (app));
        *list = g_list_prepend (*list, g_object_ref (app));
 }
 
@@ -103,7 +105,6 @@ void
 gs_plugin_status_update (GsPlugin *plugin, GsApp *app, GsPluginStatus status)
 {
        GsPluginStatusHelper *helper;
-       //return;
        helper = g_slice_new0 (GsPluginStatusHelper);
        helper->plugin = plugin;
        helper->status = status;


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