[frogr] Fixed memory issues setting sets and groups for pictures



commit f21089e5ff80b4104066a8564b7978149eb56424
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Sat Nov 10 03:13:36 2012 +0100

    Fixed memory issues setting sets and groups for pictures

 src/frogr-add-to-group-dialog.c |    6 +++++-
 src/frogr-add-to-set-dialog.c   |    6 +++++-
 src/frogr-picture.c             |    2 --
 3 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/frogr-add-to-group-dialog.c b/src/frogr-add-to-group-dialog.c
index 320b081..2ee8be0 100644
--- a/src/frogr-add-to-group-dialog.c
+++ b/src/frogr-add-to-group-dialog.c
@@ -406,12 +406,16 @@ _update_pictures (FrogrAddToGroupDialog *self)
       for (item = priv->pictures; item; item = g_slist_next (item))
         {
           picture = FROGR_PICTURE (item->data);
-          frogr_picture_set_groups (picture, selected_groups);
+
+          /* frogr_picture_set_groups expects transfer-full for groups */
+          g_slist_foreach (selected_groups, (GFunc) g_object_ref, NULL);
+          frogr_picture_set_groups (picture, g_slist_copy (selected_groups));
         }
 
       model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
       frogr_main_view_model_notify_changes_in_pictures (model);
     }
+  g_slist_free (selected_groups);
 }
 
 static void
diff --git a/src/frogr-add-to-set-dialog.c b/src/frogr-add-to-set-dialog.c
index 31b4cd6..6b641dd 100644
--- a/src/frogr-add-to-set-dialog.c
+++ b/src/frogr-add-to-set-dialog.c
@@ -407,12 +407,16 @@ _update_pictures (FrogrAddToSetDialog *self)
       for (item = priv->pictures; item; item = g_slist_next (item))
         {
           picture = FROGR_PICTURE (item->data);
-          frogr_picture_set_photosets (picture, selected_sets);
+
+          /* frogr_picture_set_photosets expects transfer-full for photosets */
+          g_slist_foreach (selected_sets, (GFunc) g_object_ref, NULL);
+          frogr_picture_set_photosets (picture, g_slist_copy (selected_sets));
         }
 
       model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
       frogr_main_view_model_notify_changes_in_pictures (model);
     }
+  g_slist_free (selected_sets);
 }
 
 static void
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index fc1b499..ce64699 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -1281,7 +1281,6 @@ frogr_picture_set_photosets (FrogrPicture *self, GSList *photosets)
   g_slist_free (priv->photosets);
 
   priv->photosets = photosets;
-  g_slist_foreach (priv->photosets, (GFunc) g_object_ref, NULL);
 }
 
 void
@@ -1348,7 +1347,6 @@ frogr_picture_set_groups (FrogrPicture *self, GSList *groups)
   g_slist_free (priv->groups);
 
   priv->groups = groups;
-  g_slist_foreach (priv->groups, (GFunc) g_object_ref, NULL);
 }
 
 void



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