[bijiben] Fix small leaks on main view notes selection
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] Fix small leaks on main view notes selection
- Date: Fri, 18 Jan 2013 00:09:04 +0000 (UTC)
commit 361d7381b976f0774c76a544a7a04f435b31ff90
Author: Pierre-Yves Luyten <py luyten fr>
Date: Fri Jan 18 01:08:38 2013 +0100
Fix small leaks on main view notes selection
src/bjb-main-view.c | 67 ++++++++++++++++++++------------------------------
1 files changed, 27 insertions(+), 40 deletions(-)
---
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index b9f44f6..2b1d3b5 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -224,23 +224,19 @@ void
action_tag_selected_notes (GtkWidget *w, BjbMainView *view)
{
GList *notes = NULL;
- gint i;
+ GList *paths, *l;
/* GtkTreePath */
- GList *paths = get_selected_paths(view);
+ paths = get_selected_paths(view);
- for ( i=0 ; i < g_list_length (paths) ; i++ )
+ for (l=paths ; l != NULL ; l=l->next)
{
- gchar *url = get_note_url_from_tree_path(g_list_nth_data(paths,i),
- view) ;
-
- notes = g_list_append(notes,
- note_book_get_note_at_path
- (bjb_window_base_get_book(view->priv->window),url));
-
+ gchar *url = get_note_url_from_tree_path (l->data, view) ;
+ notes = g_list_prepend (notes, note_book_get_note_at_path
+ (bjb_window_base_get_book(view->priv->window),url));
}
- g_list_free (paths);
+ g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
bjb_note_tag_dialog_new (GTK_WINDOW (view->priv->window), notes);
g_list_free (notes);
}
@@ -265,32 +261,26 @@ void
action_color_selected_notes (GtkWidget *w, BjbMainView *view)
{
GList *notes = NULL ;
- gint i ;
+ GList *paths, *l;
GdkRGBA color;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (w), &color);
/* GtkTreePath */
- GList *paths = get_selected_paths(view);
+ paths = get_selected_paths(view);
- for ( i=0 ; i < g_list_length (paths) ; i++ )
+ for (l=paths ; l != NULL ; l=l->next)
{
- gchar *url = get_note_url_from_tree_path(g_list_nth_data(paths,i),
- view) ;
-
- notes = g_list_append(notes,
- note_book_get_note_at_path
- (bjb_window_base_get_book(view->priv->window),url));
-
+ gchar *url = get_note_url_from_tree_path (l->data, view) ;
+ notes = g_list_prepend (notes, note_book_get_note_at_path
+ (bjb_window_base_get_book(view->priv->window),url));
}
- g_list_free (paths);
+ g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
- for (i=0 ; i<g_list_length(notes) ;i++ )
+ for (l=notes ; l != NULL ; l=l->next)
{
- BijiNoteObj *note = g_list_nth_data(notes,i) ;
-
- biji_note_obj_set_rgba (note, &color);
+ biji_note_obj_set_rgba (BIJI_NOTE_OBJ (l->data), &color);
}
g_list_free (notes);
@@ -299,29 +289,26 @@ action_color_selected_notes (GtkWidget *w, BjbMainView *view)
void
action_delete_selected_notes(GtkWidget *w,BjbMainView *view)
{
- GList *notes = NULL ;
- gint i ;
+ GList *notes = NULL;
+ GList *paths, *l;
/* GtkTreePath */
- GList *paths = get_selected_paths(view);
+ paths = get_selected_paths(view);
- for ( i=0 ; i < g_list_length (paths) ; i++ )
+ for (l=paths ; l != NULL ; l=l->next)
{
- gchar *url = get_note_url_from_tree_path(g_list_nth_data(paths,i),
- view) ;
-
- notes = g_list_append(notes,
- note_book_get_note_at_path
- (bjb_window_base_get_book(view->priv->window),url));
+ gchar *url = get_note_url_from_tree_path (l->data, view) ;
+ notes = g_list_prepend (notes, note_book_get_note_at_path
+ (bjb_window_base_get_book(view->priv->window),url));
}
- g_list_free (paths);
+ g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
- for (i=0 ; i<g_list_length(notes) ;i++ )
+ for (l=notes ; l != NULL ; l=l->next)
{
- BijiNoteObj *note = g_list_nth_data(notes,i) ;
- biji_note_book_remove_note(bjb_window_base_get_book(view->priv->window),note);
+ biji_note_book_remove_note (bjb_window_base_get_book (view->priv->window),
+ BIJI_NOTE_OBJ (l->data));
}
g_list_free (notes);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]