gui: Properly manage ref counts of combo box and tree view models.
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 25 Apr 2012 05:16:30 +0000 (22:16 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 25 Apr 2012 05:19:41 +0000 (22:19 -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.

This doesn't change PsppireValueEntry, because there's an ongoing
discussion about that.

src/ui/gui/aggregate-dialog.c
src/ui/gui/checkbox-treeview.c
src/ui/gui/compute-dialog.c
src/ui/gui/count-dialog.c
src/ui/gui/psppire-dictview.c
src/ui/gui/psppire-output-window.c
src/ui/gui/psppire-selector.c
src/ui/gui/regression-dialog.c
src/ui/gui/text-data-import-dialog.c

index ebc47d401179c464e22ac9d3b7c69ff7d57bfbd2..7a48fce850603eec83e7672ee92af4688cd19564 100644 (file)
@@ -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);
 }
 
 
index de85d18ad52aab45f4b6f8ce5b12e280ad2c144e..324943ab84364f743040503379d086acdddf9b0e 100644 (file)
@@ -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
index b9bfa2a9d36f300c4e46b1d2306c1359b4b4ee04..debc412341eca9e5af6b9ed6eaa07fae2b25cee8 100644 (file)
@@ -502,6 +502,7 @@ function_list_populate (GtkTreeView *tv)
   }
 
   gtk_tree_view_set_model (tv, GTK_TREE_MODEL (liststore));
+  g_object_unref (liststore);
 }
 
 
index 43875f963703a54f59e076b024e5a9f6a13c4f8b..b0d417f8eb1fcdf29f2358c71da3de12a11b824a 100644 (file)
@@ -165,6 +165,7 @@ void count_dialog (PsppireDataWindow *de)
     }
 
 
+  g_object_unref (cnt.value_list);
   g_object_unref (builder);
 }
 
index 0e465a3a763a9b237207441e30a3180b019f5de0..dc67b7c070fdb66811ffda29f9c7f40b6d0dc59b 100644 (file)
@@ -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
index 3000a5a03ee0228243691cbd600d95e01364f76c..61f3bbdd28f70c28dc4fd54a910b21e08a0cce09 100644 (file)
@@ -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;
 
index 79601b64faf5a9f9a5bedd91d1f83ab8095809e4..08f7f0215d8fb505d1a4c8889949e22f3589f0b1 100644 (file)
@@ -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);
     }
 }
 
index ac23fb1dcb8f7cd15303991ba33e526680a4e1d3..7c0608fd5b2032e4bc6817060367ecd1f53f68cb 100644 (file)
@@ -298,4 +298,5 @@ regression_dialog (PsppireDataWindow *de)
     }
 
   g_object_unref (xml);
+  g_object_unref (rd.stat);
 }
index c4abeaa48b2e8f5b9969972ef5bd9ea7a7201933..ec62ac0e673e0b87a005e872a4015622a03fab66 100644 (file)
@@ -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);
 }