[frogr] Fix problem with ref counting for instances of FrogrPhotoSet and FrogrGroup



commit e3f5863c3c2823d009b01290136fee22766998fc
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Sat Dec 21 08:33:39 2013 +0000

    Fix problem with ref counting for instances of FrogrPhotoSet and FrogrGroup
    
    The data type in the tree models was incorrectly declared as G_TYPE_POINTER,
    instead of G_TYPE_OBJECT, causing issues when adding/removing elements to the
    model (pictures not reffed/unreffed). Additionally, there were some missing
    and unref calls that were causing leaks each time a dialog to add a picture
    to a photoset (or create a new one) or a group was opened and then closed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720156

 src/frogr-add-to-group-dialog.c |    4 +++-
 src/frogr-add-to-set-dialog.c   |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/frogr-add-to-group-dialog.c b/src/frogr-add-to-group-dialog.c
index 783fcb5..bda3fd5 100644
--- a/src/frogr-add-to-group-dialog.c
+++ b/src/frogr-add-to-group-dialog.c
@@ -321,6 +321,7 @@ _fill_dialog_with_data (FrogrAddToGroupDialog *self)
               break;
             }
         }
+      g_object_unref (group);
 
       gtk_list_store_set (GTK_LIST_STORE (priv->treemodel), &iter,
                           CHECKBOX_COL, do_check, -1);
@@ -496,6 +497,7 @@ _frogr_add_to_group_dialog_dispose (GObject *object)
 
   if (priv->treemodel)
     {
+      gtk_list_store_clear (GTK_LIST_STORE (priv->treemodel));
       g_object_unref (priv->treemodel);
       priv->treemodel = NULL;
     }
@@ -570,7 +572,7 @@ frogr_add_to_group_dialog_init (FrogrAddToGroupDialog *self)
   priv->treemodel =
     GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_BOOLEAN,
                                         G_TYPE_STRING, G_TYPE_STRING,
-                                        G_TYPE_POINTER));
+                                        G_TYPE_OBJECT));
   gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), priv->treemodel);
 
   /* Sorting function for the number of elements column */
diff --git a/src/frogr-add-to-set-dialog.c b/src/frogr-add-to-set-dialog.c
index 8e2aac6..84c8dc2 100644
--- a/src/frogr-add-to-set-dialog.c
+++ b/src/frogr-add-to-set-dialog.c
@@ -322,6 +322,7 @@ _fill_dialog_with_data (FrogrAddToSetDialog *self)
               break;
             }
         }
+      g_object_unref (set);
 
       gtk_list_store_set (GTK_LIST_STORE (priv->treemodel), &iter,
                           CHECKBOX_COL, do_check, -1);
@@ -497,6 +498,7 @@ _frogr_add_to_set_dialog_dispose (GObject *object)
 
   if (priv->treemodel)
     {
+      gtk_list_store_clear (GTK_LIST_STORE (priv->treemodel));
       g_object_unref (priv->treemodel);
       priv->treemodel = NULL;
     }
@@ -571,7 +573,7 @@ frogr_add_to_set_dialog_init (FrogrAddToSetDialog *self)
   priv->treemodel =
     GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_BOOLEAN,
                                         G_TYPE_STRING, G_TYPE_STRING,
-                                        G_TYPE_POINTER));
+                                        G_TYPE_OBJECT));
   gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), priv->treemodel);
 
   /* Sorting function for the number of elements column */


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