gui: Properly manage ref counts of combo box and tree view models.
[pspp] / src / ui / gui / psppire-dictview.c
index 4c07d1fdc9a79291a34df4768fe2a505c35b2a62..dc67b7c070fdb66811ffda29f9c7f40b6d0dc59b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2009  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
@@ -16,7 +16,7 @@
 
 #include <config.h>
 
-#include <gtk/gtktreeview.h>
+#include <gtk/gtk.h>
 #include "psppire-dictview.h"
 #include "psppire-dict.h"
 #include "psppire-conf.h"
@@ -68,7 +68,7 @@ psppire_dict_view_finalize (GObject *object)
 {
   PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object);
 
-  g_object_unref (dict_view->menu);
+  gtk_widget_destroy (dict_view->menu);
 }
 
 /* Properties */
@@ -105,7 +105,10 @@ set_model (PsppireDictView *dict_view)
 {
   GtkTreeModel *model ;
 
-  if ( dict_view->predicate )
+  if ( dict_view->dict == NULL)
+    return;
+
+   if ( dict_view->predicate )
     {
       model = gtk_tree_model_filter_new (GTK_TREE_MODEL (dict_view->dict),
                                         NULL);
@@ -121,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
@@ -198,14 +202,14 @@ psppire_dict_view_class_init (PsppireDictViewClass *class)
   GParamSpec *predicate_spec =
     g_param_spec_pointer ("predicate",
                          "Predicate",
-                         _("A predicate function"),
+                         "A predicate function",
                          G_PARAM_READABLE | G_PARAM_WRITABLE);
 
 
   GParamSpec *selection_mode_spec =
     g_param_spec_enum ("selection-mode",
                       "Selection Mode",
-                      _("How many things can be selected"),
+                      "How many things can be selected",
                       GTK_TYPE_SELECTION_MODE,
                       GTK_SELECTION_MULTIPLE,
                       G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE);
@@ -344,7 +348,7 @@ var_icon_cell_data_func (GtkTreeViewColumn *col,
     }
   else
     {
-      const struct fmt_spec *fs = var_get_write_format (var);
+      const struct fmt_spec *fs = var_get_print_format (var);
       int cat = fmt_get_category (fs->type);
       switch ( var_get_measure (var))
        {