summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/liststore.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/wlib/gtklib/liststore.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/wlib/gtklib/liststore.c')
-rw-r--r--app/wlib/gtklib/liststore.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/app/wlib/gtklib/liststore.c b/app/wlib/gtklib/liststore.c
index eb53ea7..820366a 100644
--- a/app/wlib/gtklib/liststore.c
+++ b/app/wlib/gtklib/liststore.c
@@ -110,7 +110,8 @@ wlibListStoreGetContext(GtkListStore *ls, int inx)
/**
- * Clear the list store
+ * Clear the list store. All data in the list store will be automatically
+ * free'd when the list store is cleared.
*
* \param listStore IN
*/
@@ -118,9 +119,18 @@ wlibListStoreGetContext(GtkListStore *ls, int inx)
void
wlibListStoreClear(GtkListStore *listStore)
{
+ wListItem_p id_p;
+ int i = 0;
+
assert(listStore != NULL);
- /** \todo this looks like a memory leak. should probably free the id's */
+ id_p = wlibListStoreGetContext(listStore, i++);
+
+ while (id_p) {
+ g_free(id_p);
+ id_p = wlibListStoreGetContext(listStore, i++);
+ }
+
gtk_list_store_clear(listStore);
}
@@ -190,7 +200,9 @@ wlibListStoreUpdateIter(GtkListStore *ls, GtkTreeIter *iter, char *labels)
}
/**
- * Add a pixbuf to the list store
+ * Add a pixbuf to the list store. So pixbuf is unref'ed so it will be freed
+ * with the list store.
+ *
* \param ls IN list store
* \param iter IN position
* \param pixbuf IN pixbuf to add
@@ -200,6 +212,8 @@ void
wlibListStoreSetPixbuf(GtkListStore *ls, GtkTreeIter *iter, GdkPixbuf *pixbuf)
{
gtk_list_store_set(ls, iter, LISTCOL_BITMAP, pixbuf, -1);
+ g_object_ref_sink(pixbuf);
+ g_object_unref(pixbuf);
}
/**
* Add a row to the list store