Index: ChangeLog =================================================================== --- ChangeLog (revision 1778) +++ ChangeLog (revision 1785) @@ -1,5 +1,21 @@ -====== libgpod 0.6.0 ====== +2007-11-14 Christophe + * src/itdb_photoalbum.c: use g_list_remove all instead of an + inefficient combination of g_list_find + g_list_remove + +2007-11-14 Jorg Schuler + + * src/itdb_photoalbum.c (itdb_photodb_photoalbum_remove): make + sure same photo isn't freed multiple times if it was added in an + album multiple times. + +2007-11-13 Christophe Fergeau + + * 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 + 2007-11-10 Christophe Fergeau * Makefile.am: add README.SysInfo to EXTRADIST Index: src/itdb_photoalbum.c =================================================================== --- src/itdb_photoalbum.c (revision 1778) +++ src/itdb_photoalbum.c (revision 1785) @@ -1,4 +1,4 @@ -/* Time-stamp: <2007-11-03 20:27:36 jcs> +/* | | Copyright (C) 2002-2006 Jorg Schuler | Part of the gtkpod project. @@ -615,10 +615,7 @@ for (it = db->photoalbums; it != NULL; it = it->next) { Itdb_PhotoAlbum *_album = it->data; - while (g_list_find (_album->members, photo)) - { - _album->members = g_list_remove (_album->members, photo); - } + _album->members = g_list_remove_all (_album->members, photo); } /* Remove the photo from the image list */ db->photos = g_list_remove (db->photos, photo); @@ -678,8 +675,6 @@ Itdb_PhotoAlbum *album, gboolean remove_pics) { - GList *it; - g_return_if_fail (db); g_return_if_fail (album); @@ -687,11 +682,16 @@ * and remove them from the database */ if (remove_pics) { - for (it = album->members; it != NULL; it = it->next ) + /* we can't iterate over album->members because + itdb_photodb_remove_photo() modifies album->members in + a not easily predicable way (e.g. @photo may exist in the + album several times). Therefore we remove photos until + album->members is empty. */ + while (album->members) { - Itdb_Artwork *photo = it->data; - itdb_photodb_remove_photo (db, NULL, photo); - } + Itdb_Artwork *photo = album->members->data; + itdb_photodb_remove_photo (db, NULL, photo); + } } db->photoalbums = g_list_remove (db->photoalbums, album); itdb_photodb_photoalbum_free (album);