[easytag/wip/awinkelmann: 2/2] Fixed a memory leak
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/awinkelmann: 2/2] Fixed a memory leak
- Date: Fri, 6 Jun 2014 22:13:54 +0000 (UTC)
commit 4ef4470339d950fc7bb68be258d9b027a98b7f21
Author: Andreas Winkelmann <ml awinkelmann de>
Date: Fri Jun 6 23:10:42 2014 +0100
Fixed a memory leak
In Artist/Album-View the Album-List contains a row for a collection of
all Albums for an Artist - the "<All Albums>" row. The attached List was
not freed.
Added a Column with a Boolean Value to the Model to be able to identify
this Row. String-Comparison seems unsafe. Additional Lists to free these
lists also.
src/browser.c | 33 ++++++++++++++++++++++++++++++---
src/browser.h | 1 +
2 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 97e0227..8f10b10 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -2139,6 +2139,31 @@ void
browser_album_model_clear (void)
{
GtkTreeSelection *selection;
+ gboolean valid;
+ GtkTreeIter iter;
+
+ /* Free the attached list in the "all albums" row. */
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (albumListModel),
+ &iter);
+
+ while (valid)
+ {
+ GList *l;
+ gboolean all_albums_row = FALSE;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (albumListModel), &iter,
+ ALBUM_ETFILE_LIST_POINTER, &l,
+ ALBUM_ALL_ALBUMS_ROW, &all_albums_row, -1);
+
+ if (all_albums_row && l)
+ {
+ g_list_free (l);
+ break;
+ }
+
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (albumListModel),
+ &iter);
+ }
/* Empty model, disable Browser_Album_List_Row_Selected () during clear
* because it is called and crashed. */
@@ -2179,7 +2204,6 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList));
// Create a first row to select all albums of the artist
- // FIX ME : the attached list must be freed!
for (l = albumlist; l != NULL; l = g_list_next (l))
{
GList *etfilelist_tmp;
@@ -2195,6 +2219,7 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
ALBUM_NUM_FILES,
g_list_length (g_list_first (etfilelist)),
ALBUM_ETFILE_LIST_POINTER, etfilelist,
+ ALBUM_ALL_ALBUMS_ROW, TRUE,
-1);
// Create a line for each album of the artist
@@ -2217,7 +2242,8 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
ALBUM_NUM_FILES,
g_list_length (g_list_first (etfilelist)),
ALBUM_ETFILE_LIST_POINTER,
- etfilelist, -1);
+ etfilelist,
+ ALBUM_ALL_ALBUMS_ROW, FALSE, -1);
g_object_unref (icon);
@@ -3372,7 +3398,8 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
G_TYPE_POINTER,
PANGO_TYPE_STYLE,
G_TYPE_INT,
- GDK_TYPE_COLOR);
+ GDK_TYPE_COLOR,
+ G_TYPE_BOOLEAN);
BrowserAlbumList = gtk_tree_view_new_with_model(GTK_TREE_MODEL(albumListModel));
g_object_unref (albumListModel);
diff --git a/src/browser.h b/src/browser.h
index db6850c..c1bcfb5 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -121,6 +121,7 @@ enum
ALBUM_FONT_STYLE,
ALBUM_FONT_WEIGHT,
ALBUM_ROW_FOREGROUND,
+ ALBUM_ALL_ALBUMS_ROW,
ALBUM_COLUMN_COUNT
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]