[gnome-software] category: Use a weak ref for the parent



commit c340d6ba89c7d9ec397eb5afed2851c439a0572f
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Mar 15 16:27:30 2015 +0100

    category: Use a weak ref for the parent
    
    Likely to help with the crash in
    https://bugzilla.redhat.com/show_bug.cgi?id=1060201

 src/gs-category.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-category.c b/src/gs-category.c
index 9c00a42..2c96b25 100644
--- a/src/gs-category.c
+++ b/src/gs-category.c
@@ -188,6 +188,9 @@ gs_category_finalize (GObject *object)
        GsCategory *category = GS_CATEGORY (object);
        GsCategoryPrivate *priv = category->priv;
 
+       if (priv->parent != NULL)
+               g_object_remove_weak_pointer (G_OBJECT (priv->parent),
+                                             (gpointer *) &priv->parent);
        g_free (priv->id);
        g_free (priv->name);
        g_list_free_full (priv->subcategories, g_object_unref);
@@ -209,6 +212,9 @@ gs_category_new (GsCategory *parent, const gchar *id, const gchar *name)
 
        category = g_object_new (GS_TYPE_CATEGORY, NULL);
        category->priv->parent = parent;
+       if (category->priv->parent != NULL)
+               g_object_add_weak_pointer (G_OBJECT (category->priv->parent),
+                                          (gpointer *) &category->priv->parent);
        category->priv->id = g_strdup (id);
        category->priv->name = g_strdup (name);
        return GS_CATEGORY (category);


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