summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2007-11-13 20:13:07 +0000
committerChristophe Fergeau <teuf@gnome.org>2007-11-13 20:13:07 +0000
commit80b3f15a39e3f7b797ededf9c86508ade7b39382 (patch)
tree7a66337c882cbf2ff3b7567e2ccbf4cebef0212a
parent4946bf11068a78809b322964186c9b2856845889 (diff)
downloadlibgpod-80b3f15a39e3f7b797ededf9c86508ade7b39382.tar.gz
libgpod-80b3f15a39e3f7b797ededf9c86508ade7b39382.tar.xz
libgpod-80b3f15a39e3f7b797ededf9c86508ade7b39382.zip
* src/itdb_photoalbum.c: fix bug in itdb_photodb_photoalbum_remove,
when removing all the photos from the photodatabase, we were erasing elements and iterating over the list at the same time, which resulted in the function not working properly git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1778 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r--ChangeLog7
-rw-r--r--src/itdb_photoalbum.c12
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 665b46f..2601357 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-13 Christophe Fergeau <teuf@gnome.org>
+
+ * src/itdb_photoalbum.c: fix bug in itdb_photodb_photoalbum_remove,
+ when removing all the photos from the photodatabase, we were
+ erasing elements and iterating over the list at the same time,
+ which resulted in the function not working properly
+
====== libgpod 0.6.0 ======
2007-11-10 Christophe Fergeau <teuf@gnome.org>
diff --git a/src/itdb_photoalbum.c b/src/itdb_photoalbum.c
index 001b86a..7656a64 100644
--- a/src/itdb_photoalbum.c
+++ b/src/itdb_photoalbum.c
@@ -687,11 +687,21 @@ void itdb_photodb_photoalbum_remove (Itdb_PhotoDB *db,
* and remove them from the database */
if (remove_pics)
{
- for (it = album->members; it != NULL; it = it->next )
+ GList *pics;
+ /* we can't let itdb_photodb_remove_photo modify album->members
+ * while we're iterating through it, that's it's moved to pics
+ * first. itdb_photodb_remove_photo frees the memory used
+ * by 'photo' so a g_list_free is all we have to do to free
+ * pics memory when we are done iterating
+ */
+ pics = album->members;
+ album->members = NULL;
+ for (it = pics; it != NULL; it = it->next )
{
Itdb_Artwork *photo = it->data;
itdb_photodb_remove_photo (db, NULL, photo);
}
+ g_list_free (pics);
}
db->photoalbums = g_list_remove (db->photoalbums, album);
itdb_photodb_photoalbum_free (album);