Fix memory leaks in gui
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 3 Feb 2008 05:26:05 +0000 (05:26 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 3 Feb 2008 05:26:05 +0000 (05:26 +0000)
src/ui/gui/dialog-common.c
src/ui/gui/helper.c
src/ui/gui/recode-dialog.c

index bbdc36a2d6bd3260a0d67cd09737c165ff9e0a1a..0aab294e12ef0b2a8ca937851f60533525847619 100644 (file)
@@ -193,16 +193,15 @@ homogeneous_types (GtkWidget *source, GtkWidget *dest)
   for (l = list; l ; l = l->next)
     {
       GtkTreePath *path = l->data;
-      GtkTreePath *fpath;
-      gint *idx;
 
-      const struct variable *v;
+      GtkTreePath *fpath =
+       gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (model), path);
 
-      fpath = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (model), path);
+      gint *idx = gtk_tree_path_get_indices (fpath);
 
-      idx = gtk_tree_path_get_indices (fpath);
+      const struct variable *v = psppire_dict_get_variable (dict, idx[0]);
 
-      v = psppire_dict_get_variable (dict, idx[0]);
+      gtk_tree_path_free (fpath);
 
       if ( type != -1 )
        {
index 9cbd6f0f2a9d9bf6991da032358d344e25d505a6..da74882a8f0bbae0557c91b3d6de82256a6e490b 100644 (file)
@@ -336,6 +336,8 @@ clone_list_store (const GtkListStore *src)
       row++;
     }
 
+  g_free (types);
+
   return dest;
 }
 
index b233f116d88e14092682e875e5722f8aaa74a115..3468e580c8fe8068cb3306110bfcee92fd82ffab 100644 (file)
@@ -326,7 +326,6 @@ struct recode_dialog
   GtkWidget *ov_high_down_entry;
 
   GtkListStore *value_map;
-  GtkListStore *local_store;
 
   /* Indicates that the INTO {new variables} form of the dialog
      is being used */
@@ -1110,6 +1109,10 @@ recode_dialog (struct data_editor *de, gboolean diff)
       break;
     }
 
+
+  gtk_list_store_clear (GTK_LIST_STORE (rd.value_map));
+  g_object_unref (rd.value_map);
+
   g_object_unref (xml);
 }
 
@@ -1263,11 +1266,9 @@ static void
 run_old_and_new_dialog (struct recode_dialog *rd)
 {
   gint response;
-  rd->local_store = clone_list_store (rd->value_map);
-
-  g_object_ref (rd->local_store);
+  GtkListStore *local_store = clone_list_store (rd->value_map);
 
-  psppire_acr_set_model (rd->acr, rd->local_store);
+  psppire_acr_set_model (rd->acr, local_store);
   psppire_acr_set_get_value_func (rd->acr, set_value, rd);
 
   gtk_window_set_title (GTK_WINDOW (rd->old_and_new_dialog),
@@ -1316,7 +1317,12 @@ run_old_and_new_dialog (struct recode_dialog *rd)
 
 
   if ( response == PSPPIRE_RESPONSE_CONTINUE )
-      rd->value_map = clone_list_store (rd->local_store);
+    {
+      g_object_unref (rd->value_map);
+      rd->value_map = clone_list_store (local_store);
+    }
+  else
+    g_object_unref (local_store);
 
 
   psppire_dialog_notify_change (PSPPIRE_DIALOG (rd->dialog));