From: John Darrington Date: Sun, 3 Feb 2008 05:26:05 +0000 (+0000) Subject: Fix memory leaks in gui X-Git-Tag: v0.6.0~140 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bcb0e4c5d3084983b86675187088bb3ad906cc2;p=pspp-builds.git Fix memory leaks in gui --- diff --git a/src/ui/gui/dialog-common.c b/src/ui/gui/dialog-common.c index bbdc36a2..0aab294e 100644 --- a/src/ui/gui/dialog-common.c +++ b/src/ui/gui/dialog-common.c @@ -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 ) { diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 9cbd6f0f..da74882a 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -336,6 +336,8 @@ clone_list_store (const GtkListStore *src) row++; } + g_free (types); + return dest; } diff --git a/src/ui/gui/recode-dialog.c b/src/ui/gui/recode-dialog.c index b233f116..3468e580 100644 --- a/src/ui/gui/recode-dialog.c +++ b/src/ui/gui/recode-dialog.c @@ -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));