[network-manager-netbook] Fix a memory leak
- From: Tambet Ingo <tambeti src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] Fix a memory leak
- Date: Tue, 2 Mar 2010 20:34:35 +0000 (UTC)
commit c247e364c43b935ffe8af60f3f0b6fc857c46ee5
Author: Tambet Ingo <tambet gmail com>
Date: Tue Mar 2 14:47:56 2010 -0400
Fix a memory leak
If an inserted row to the model has value at the time of insertion (which
is always the case, at least for now), then let the renderer know about it
right away. At the moment, it's an optimization, pretty soon we'll create
a different renderer based on the item.
src/nmn-list.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/nmn-list.c b/src/nmn-list.c
index c192413..9c6b9c9 100644
--- a/src/nmn-list.c
+++ b/src/nmn-list.c
@@ -196,8 +196,10 @@ nmn_list_layout (NmnList *self)
}
gtk_tree_model_get (priv->model, &iter, NM_LIST_MODEL_COL_ITEM, &item, -1);
- if (item)
+ if (item) {
nmn_item_renderer_set_item (renderer, item);
+ g_object_unref (item);
+ }
}
if (item) {
@@ -263,16 +265,25 @@ model_row_inserted (GtkTreeModel *model,
NmnListPrivate *priv = GET_PRIVATE (self);
NmnItemRenderer *renderer;
GSList *list;
+ NMListItem *item;
int index;
index = gtk_tree_path_get_indices (path)[0];
+ gtk_tree_model_get (model, iter, NM_LIST_MODEL_COL_ITEM, &item, -1);
+ g_debug ("Inserted row, has item %p", item);
+
renderer = (NmnItemRenderer *) nmn_network_renderer_new ();
renderer->index = index;
if (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_ITERS_PERSIST)
renderer->iter = *iter;
+ if (item) {
+ nmn_item_renderer_set_item (renderer, item);
+ g_object_unref (item);
+ }
+
priv->rows = g_slist_insert (priv->rows, g_object_ref_sink (renderer), index);
list = g_slist_nth (priv->rows, index + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]