[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] gui: Properly manage ref counts of combo box and tree view m
From: |
Ben Pfaff |
Subject: |
[PATCH 2/2] gui: Properly manage ref counts of combo box and tree view models. |
Date: |
Mon, 23 Apr 2012 22:19:06 -0700 |
gtk_combo_box_set_model() and gtk_tree_view_set_model() add a
reference to the passed-in model, instead of transferring a
reference from the caller. A lot of the calls to these functions,
however, assumed that a reference was transferred and therefore
leaked a reference. This fixes them up.
I didn't change PsppireValueEntry, which also has a problem, because
John is working on that.
---
src/ui/gui/aggregate-dialog.c | 1 +
src/ui/gui/checkbox-treeview.c | 6 ++++--
src/ui/gui/compute-dialog.c | 1 +
src/ui/gui/count-dialog.c | 1 +
src/ui/gui/psppire-dictview.c | 3 ++-
src/ui/gui/psppire-output-window.c | 8 +++++---
src/ui/gui/psppire-selector.c | 4 +++-
src/ui/gui/regression-dialog.c | 1 +
src/ui/gui/text-data-import-dialog.c | 2 ++
9 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/ui/gui/aggregate-dialog.c b/src/ui/gui/aggregate-dialog.c
index b3f3564..ae1cf6e 100644
--- a/src/ui/gui/aggregate-dialog.c
+++ b/src/ui/gui/aggregate-dialog.c
@@ -226,6 +226,7 @@ populate_combo_model (GtkComboBox *cb)
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cb), renderer, "text", 0);
gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list));
+ g_object_unref (list);
}
diff --git a/src/ui/gui/checkbox-treeview.c b/src/ui/gui/checkbox-treeview.c
index de85d18..324943a 100644
--- a/src/ui/gui/checkbox-treeview.c
+++ b/src/ui/gui/checkbox-treeview.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007 Free Software Foundation
+ Copyright (C) 2007, 2012 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -55,7 +55,6 @@ treeview_create_checkbox_model (GtkTreeView *treeview,
list = gtk_list_store_new (N_CHECKBOX_COLUMNS,
G_TYPE_STRING, G_TYPE_BOOLEAN);
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (list));
for (i = 0; i < n_items; i++)
{
@@ -67,6 +66,9 @@ treeview_create_checkbox_model (GtkTreeView *treeview,
(default_items & (1u << i)) != 0,
-1);
}
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (list));
+ g_object_unref (list);
}
static void
diff --git a/src/ui/gui/compute-dialog.c b/src/ui/gui/compute-dialog.c
index b9bfa2a..debc412 100644
--- a/src/ui/gui/compute-dialog.c
+++ b/src/ui/gui/compute-dialog.c
@@ -502,6 +502,7 @@ function_list_populate (GtkTreeView *tv)
}
gtk_tree_view_set_model (tv, GTK_TREE_MODEL (liststore));
+ g_object_unref (liststore);
}
diff --git a/src/ui/gui/count-dialog.c b/src/ui/gui/count-dialog.c
index 43875f9..b0d417f 100644
--- a/src/ui/gui/count-dialog.c
+++ b/src/ui/gui/count-dialog.c
@@ -165,6 +165,7 @@ void count_dialog (PsppireDataWindow *de)
}
+ g_object_unref (cnt.value_list);
g_object_unref (builder);
}
diff --git a/src/ui/gui/psppire-dictview.c b/src/ui/gui/psppire-dictview.c
index 0e465a3..dc67b7c 100644
--- a/src/ui/gui/psppire-dictview.c
+++ b/src/ui/gui/psppire-dictview.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2009, 2010, 2011 Free Software Foundation
+ Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -124,6 +124,7 @@ set_model (PsppireDictView *dict_view)
}
gtk_tree_view_set_model (GTK_TREE_VIEW (dict_view), model);
+ g_object_unref (model);
}
static void
diff --git a/src/ui/gui/psppire-output-window.c
b/src/ui/gui/psppire-output-window.c
index 3000a5a..61f3bbd 100644
--- a/src/ui/gui/psppire-output-window.c
+++ b/src/ui/gui/psppire-output-window.c
@@ -955,6 +955,7 @@ psppire_output_window_init (PsppireOutputWindow *window)
GtkAction *copy_action;
GtkAction *select_all_action;
GtkTreeSelection *sel;
+ GtkTreeModel *model;
string_map_init (&window->render_opts);
@@ -982,12 +983,13 @@ psppire_output_window_init (PsppireOutputWindow *window)
g_signal_connect (sel, "changed", G_CALLBACK (on_selection_change),
copy_action);
- gtk_tree_view_set_model (window->overview,
- GTK_TREE_MODEL (gtk_tree_store_new (
+ model = GTK_TREE_MODEL (gtk_tree_store_new (
N_COLS,
G_TYPE_STRING, /* COL_TITLE */
G_TYPE_POINTER, /* COL_ADDR */
- G_TYPE_LONG))); /* COL_Y */
+ G_TYPE_LONG)); /* COL_Y */
+ gtk_tree_view_set_model (window->overview, model);
+ g_object_unref (model);
window->in_command = false;
diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c
index 79601b6..08f7f02 100644
--- a/src/ui/gui/psppire-selector.c
+++ b/src/ui/gui/psppire-selector.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2009, 2010 Free Software Foundation
+ Copyright (C) 2007, 2009, 2010, 2012 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -812,6 +812,8 @@ update_model (
g_signal_connect_swapped (new_model,
"row-inserted",
G_CALLBACK (on_row_inserted), selector);
+
+ g_object_unref (new_model);
}
}
diff --git a/src/ui/gui/regression-dialog.c b/src/ui/gui/regression-dialog.c
index ac23fb1..7c0608f 100644
--- a/src/ui/gui/regression-dialog.c
+++ b/src/ui/gui/regression-dialog.c
@@ -298,4 +298,5 @@ regression_dialog (PsppireDataWindow *de)
}
g_object_unref (xml);
+ g_object_unref (rd.stat);
}
diff --git a/src/ui/gui/text-data-import-dialog.c
b/src/ui/gui/text-data-import-dialog.c
index c4abeaa..ec62ac0 100644
--- a/src/ui/gui/text-data-import-dialog.c
+++ b/src/ui/gui/text-data-import-dialog.c
@@ -1077,6 +1077,7 @@ set_quote_list (GtkComboBoxEntry *cb)
}
gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list));
+ g_object_unref (list);
gtk_combo_box_entry_set_text_column (cb, 0);
}
@@ -1954,6 +1955,7 @@ make_tree_view (const struct import_assistant *ia,
g_object_set_data (G_OBJECT (model), "first-line",
GINT_TO_POINTER (first_line));
gtk_tree_view_set_model (*tree_view, model);
+ g_object_unref (model);
add_line_number_column (ia, *tree_view);
}
--
1.7.2.5