[easytag/wip/gsettings] Unref icons after setting them on a model
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/gsettings] Unref icons after setting them on a model
- Date: Thu, 21 Mar 2013 08:39:48 +0000 (UTC)
commit 9531107eb8577d10ba612f4c74e816ecd1c69f3c
Author: David King <amigadave amigadave com>
Date: Thu Mar 21 06:37:51 2013 +0000
Unref icons after setting them on a model
GThemedIcon, GEmblem and GEmblemedIcon inherit from GObject, not
GInitiallyUnowned, so must be explicitly unreffed after adding them to a
GtkListStore (which adds a reference in addition to the initial
reference upon creation).
src/browser.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 9060684..b633b9a 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -2362,6 +2362,7 @@ Browser_Tree_Initialize (void)
{
GtkTreeIter parent_iter;
GtkTreeIter dummy_iter;
+ GIcon *drive_icon;
g_return_if_fail (directoryTreeModel != NULL);
@@ -2370,7 +2371,6 @@ Browser_Tree_Initialize (void)
#ifdef G_OS_WIN32
/* Code strangely familiar with gtkfilesystemwin32.c */
- GIcon *drive_icon;
DWORD drives;
UINT drive_type;
gchar drive[4] = "A:/";
@@ -2446,17 +2446,20 @@ Browser_Tree_Initialize (void)
}
#else /* !G_OS_WIN32 */
+ drive_icon = g_themed_icon_new ("folder");
gtk_tree_store_append(directoryTreeModel, &parent_iter, NULL);
gtk_tree_store_set(directoryTreeModel, &parent_iter,
TREE_COLUMN_DIR_NAME, G_DIR_SEPARATOR_S,
TREE_COLUMN_FULL_PATH, G_DIR_SEPARATOR_S,
TREE_COLUMN_HAS_SUBDIR, TRUE,
TREE_COLUMN_SCANNED, FALSE,
- TREE_COLUMN_ICON, g_themed_icon_new ("folder"),
+ TREE_COLUMN_ICON, drive_icon,
-1);
// insert dummy node
gtk_tree_store_append(directoryTreeModel, &dummy_iter, &parent_iter);
#endif /* !G_OS_WIN32 */
+
+ g_object_unref (drive_icon);
}
/*
@@ -2765,11 +2768,18 @@ get_gicon_for_path (const gchar *path)
{
GEmblem *unreadable_emblem;
GIcon *unreadable_icon;
+ GIcon *emblemed_icon;
unreadable_icon = g_themed_icon_new ("emblem-unreadable");
unreadable_emblem = g_emblem_new_with_origin (unreadable_icon,
G_EMBLEM_ORIGIN_LIVEMETADATA);
- return g_emblemed_icon_new (folder_icon, unreadable_emblem);
+ emblemed_icon = g_emblemed_icon_new (folder_icon,
+ unreadable_emblem);
+ g_object_unref (folder_icon);
+ g_object_unref (unreadable_icon);
+ g_object_unref (unreadable_emblem);
+
+ return emblemed_icon;
}
} else
{
@@ -2894,6 +2904,7 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
gtk_tree_store_append(directoryTreeModel, &subNodeIter, ¤tIter);
}
+ g_object_unref (icon);
g_free(fullpath_file);
g_free(dirname_utf8);
}
@@ -2907,6 +2918,7 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
gtk_tree_model_iter_children(GTK_TREE_MODEL(directoryTreeModel), &subNodeIter, iter);
gtk_tree_store_remove(directoryTreeModel, &subNodeIter);
+ icon = g_themed_icon_new ("folder-open");
#ifdef G_OS_WIN32
// set open folder pixmap except on drive (depth == 0)
if (gtk_tree_path_get_depth(gtreePath) > 1)
@@ -2914,26 +2926,28 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
// update the icon of the node to opened folder :-)
gtk_tree_store_set(directoryTreeModel, iter,
TREE_COLUMN_SCANNED, TRUE,
- TREE_COLUMN_ICON, g_themed_icon_new ("folder-open"),
+ TREE_COLUMN_ICON, icon,
-1);
}
#else /* !G_OS_WIN32 */
// update the icon of the node to opened folder :-)
gtk_tree_store_set(directoryTreeModel, iter,
TREE_COLUMN_SCANNED, TRUE,
- TREE_COLUMN_ICON, g_themed_icon_new ("folder-open"),
+ TREE_COLUMN_ICON, icon,
-1);
#endif /* !G_OS_WIN32 */
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(directoryTreeModel),
TREE_COLUMN_DIR_NAME, GTK_SORT_ASCENDING);
+ g_object_unref (icon);
g_free(parentPath);
}
static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data)
{
GtkTreeIter subNodeIter;
+ GIcon *icon;
g_return_if_fail (directoryTreeModel != NULL);
@@ -2945,6 +2959,7 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
gtk_tree_store_remove(directoryTreeModel, &subNodeIter);
}
+ icon = g_themed_icon_new ("folder-open");
#ifdef G_OS_WIN32
// set closed folder pixmap except on drive (depth == 0)
if(gtk_tree_path_get_depth(treePath) > 1)
@@ -2952,17 +2967,19 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
// update the icon of the node to closed folder :-)
gtk_tree_store_set(directoryTreeModel, iter,
TREE_COLUMN_SCANNED, FALSE,
- TREE_COLUMN_ICON, g_themed_icon_new ("folder"), -1);
+ TREE_COLUMN_ICON, icon, -1);
}
#else /* !G_OS_WIN32 */
// update the icon of the node to closed folder :-)
gtk_tree_store_set(directoryTreeModel, iter,
TREE_COLUMN_SCANNED, FALSE,
- TREE_COLUMN_ICON, g_themed_icon_new ("folder"), -1);
+ TREE_COLUMN_ICON, icon, -1);
#endif /* !G_OS_WIN32 */
// insert dummy node
gtk_tree_store_append(directoryTreeModel, &subNodeIter, iter);
+
+ g_object_unref (icon);
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]