mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
Fixed some memory leaks in divelist.c related to gtk_tree_iter_copy()
divelist.c: get_iter_from_idx() goes trought the tree model and calls iter_has_index(), until a match is found. when the match is found we use gtk_tree_iter_copy() to make a copy of the iterator. This means that the caller of get_iter_from_idx() has to take care the de-allocation using gtk_tree_iter_free(). Also take care of the eventual: parent = gtk_tree_iter_copy(...) allocation in select_prev_dive(), select_next_dive() Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3848cac30f
commit
363c38f557
1 changed files with 9 additions and 2 deletions
11
divelist.c
11
divelist.c
|
@ -2953,11 +2953,12 @@ void show_and_select_dive(struct dive *dive)
|
||||||
selected_dive = divenr;
|
selected_dive = divenr;
|
||||||
dive->selected = TRUE;
|
dive->selected = TRUE;
|
||||||
go_to_iter(selection, iter);
|
go_to_iter(selection, iter);
|
||||||
|
gtk_tree_iter_free(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_next_dive(void)
|
void select_next_dive(void)
|
||||||
{
|
{
|
||||||
GtkTreeIter *nextiter, *parent;
|
GtkTreeIter *nextiter, *parent = NULL;
|
||||||
GtkTreeIter *iter = get_iter_from_idx(selected_dive);
|
GtkTreeIter *iter = get_iter_from_idx(selected_dive);
|
||||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view));
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view));
|
||||||
int idx;
|
int idx;
|
||||||
|
@ -2983,11 +2984,14 @@ void select_next_dive(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
go_to_iter(selection, nextiter);
|
go_to_iter(selection, nextiter);
|
||||||
|
if (parent)
|
||||||
|
gtk_tree_iter_free(parent);
|
||||||
|
gtk_tree_iter_free(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_prev_dive(void)
|
void select_prev_dive(void)
|
||||||
{
|
{
|
||||||
GtkTreeIter previter, *parent;
|
GtkTreeIter previter, *parent = NULL;
|
||||||
GtkTreeIter *iter = get_iter_from_idx(selected_dive);
|
GtkTreeIter *iter = get_iter_from_idx(selected_dive);
|
||||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view));
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view));
|
||||||
GtkTreePath *treepath;
|
GtkTreePath *treepath;
|
||||||
|
@ -3021,4 +3025,7 @@ void select_prev_dive(void)
|
||||||
go_to_iter(selection, &previter);
|
go_to_iter(selection, &previter);
|
||||||
free_path:
|
free_path:
|
||||||
gtk_tree_path_free(treepath);
|
gtk_tree_path_free(treepath);
|
||||||
|
if (parent)
|
||||||
|
gtk_tree_iter_free(parent);
|
||||||
|
gtk_tree_iter_free(iter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue