Mercurial > geeqie
changeset 1656:349ebc02b8e2
fixed leak in file_util_* functions
- file_util_* are changed to take over the filelist and free it when
done
- make sure that these functions are called correctly
author | nadvornik |
---|---|
date | Sat, 20 Jun 2009 18:42:23 +0000 |
parents | 6600a2754e50 |
children | 00673c03d856 |
files | src/collect-table.c src/collect.c src/dupe.c src/layout_util.c src/metadata.c src/search.c src/utilops.c src/utilops.h src/view_dir.c src/view_file.c |
diffstat | 10 files changed, 20 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/src/collect-table.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/collect-table.c Sat Jun 20 18:42:23 2009 +0000 @@ -657,18 +657,12 @@ { CollectTable *ct; const gchar *key = data; - GList *list; ct = submenu_item_get_data(widget); if (!ct) return; - list = collection_table_popup_file_list(ct); - if (list) - { - file_util_start_editor_from_filelist(key, list, NULL, ct->listview); - filelist_free(list); - } + file_util_start_editor_from_filelist(key, collection_table_popup_file_list(ct), NULL, ct->listview); } static void collection_table_popup_copy_cb(GtkWidget *widget, gpointer data)
--- a/src/collect.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/collect.c Sat Jun 20 18:42:23 2009 +0000 @@ -968,14 +968,6 @@ break; } } -#if 0 - if (edit_val != -1) - { - list = collection_table_selection_get_list(cw->table); - file_util_start_editor_from_filelist(edit_val, list, cw->window); - filelist_free(list); - } -#endif return stop_signal; }
--- a/src/dupe.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/dupe.c Sat Jun 20 18:42:23 2009 +0000 @@ -2042,13 +2042,7 @@ static void dupe_window_edit_selected(DupeWindow *dw, const gchar *key) { - GList *list; - - list = dupe_listview_get_selection(dw, dw->listview); - - file_util_start_editor_from_filelist(key, list, NULL, dw->window); - - filelist_free(list); + file_util_start_editor_from_filelist(key, dupe_listview_get_selection(dw, dw->listview), NULL, dw->window); } static void dupe_window_collection_from_selection(DupeWindow *dw)
--- a/src/layout_util.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/layout_util.c Sat Jun 20 18:42:23 2009 +0000 @@ -991,15 +991,12 @@ static void layout_menu_edit_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - GList *list; const gchar *key = gtk_action_get_name(action); if (!editor_window_flag_set(key)) layout_exit_fullscreen(lw); - list = layout_selection_list(lw); - file_util_start_editor_from_filelist(key, list, layout_get_path(lw), lw->window); - filelist_free(list); + file_util_start_editor_from_filelist(key, layout_selection_list(lw), layout_get_path(lw), lw->window); } #if 0
--- a/src/metadata.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/metadata.c Sat Jun 20 18:42:23 2009 +0000 @@ -144,8 +144,6 @@ file_util_write_metadata(NULL, to_approve, NULL, force_dialog, done_func, done_data); - filelist_free(to_approve); - return (metadata_write_queue != NULL); }
--- a/src/search.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/search.c Sat Jun 20 18:42:23 2009 +0000 @@ -662,11 +662,7 @@ static void search_result_edit_selected(SearchData *sd, const gchar *key) { - GList *list; - - list = search_result_selection_list(sd); - file_util_start_editor_from_filelist(key, list, NULL, sd->window); - filelist_free(list); + file_util_start_editor_from_filelist(key, search_result_selection_list(sd), NULL, sd->window); } static void search_result_collection_from_selection(SearchData *sd)
--- a/src/utilops.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/utilops.c Sat Jun 20 18:42:23 2009 +0000 @@ -1931,10 +1931,9 @@ } } -static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) +static void file_util_delete_full(FileData *source_fd, GList *flist, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *flist = filelist_copy(source_list); GList *ungrouped = NULL; if (source_fd) @@ -1979,10 +1978,9 @@ } -static void file_util_write_metadata_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data) +static void file_util_write_metadata_full(FileData *source_fd, GList *flist, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data) { UtilityData *ud; - GList *flist = filelist_copy(source_list); if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); @@ -2023,10 +2021,9 @@ file_util_dialog_run(ud); } -static void file_util_move_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) +static void file_util_move_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *flist = filelist_copy(source_list); GList *ungrouped = NULL; if (source_fd) @@ -2070,10 +2067,9 @@ file_util_dialog_run(ud); } -static void file_util_copy_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) +static void file_util_copy_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *flist = filelist_copy(source_list); GList *ungrouped = NULL; if (source_fd) @@ -2117,10 +2113,9 @@ file_util_dialog_run(ud); } -static void file_util_rename_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) +static void file_util_rename_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *flist = filelist_copy(source_list); GList *ungrouped = NULL; if (source_fd) @@ -2164,10 +2159,9 @@ file_util_dialog_run(ud); } -static void file_util_start_editor_full(const gchar *key, FileData *source_fd, GList *source_list, const gchar *dest_path, const gchar *working_directory, GtkWidget *parent, UtilityPhase phase) +static void file_util_start_editor_full(const gchar *key, FileData *source_fd, GList *flist, const gchar *dest_path, const gchar *working_directory, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *flist; GList *ungrouped = NULL; if (editor_no_param(key)) @@ -2179,18 +2173,18 @@ if (source_fd) file_directory = remove_level_from_path(source_fd->path); - if (!file_directory && source_list) - file_directory = remove_level_from_path(((FileData *)source_list->data)->path); + if (!file_directory && flist) + file_directory = remove_level_from_path(((FileData *)flist->data)->path); working_directory = file_directory; } /* just start the editor, don't care about files */ start_editor(key, working_directory); g_free(file_directory); + filelist_free(flist); return; } - flist = filelist_copy(source_list); if (source_fd) { @@ -2794,5 +2788,6 @@ gtk_clipboard_set_text(clipboard, new->str, new->len); g_string_free(new, TRUE); + filelist_free(list); } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- a/src/utilops.h Sat Jun 20 16:46:32 2009 +0000 +++ b/src/utilops.h Sat Jun 20 18:42:23 2009 +0000 @@ -33,6 +33,8 @@ GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message, const gchar *icon_stock_id, GtkWidget *parent); +/* all functions takes over the filelist and frees it when done */ + void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent); void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent); void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent);
--- a/src/view_dir.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/view_dir.c Sat Jun 20 18:42:23 2009 +0000 @@ -822,11 +822,13 @@ { file_util_copy_simple(list, fd->path, vd->widget); done = TRUE; + list = NULL; } else if (context->actions == GDK_ACTION_MOVE) { file_util_move_simple(list, fd->path, vd->widget); done = TRUE; + list = NULL; } }
--- a/src/view_file.c Sat Jun 20 16:46:32 2009 +0000 +++ b/src/view_file.c Sat Jun 20 18:42:23 2009 +0000 @@ -314,15 +314,12 @@ { ViewFile *vf; const gchar *key = data; - GList *list; vf = submenu_item_get_data(widget); if (!vf) return; - list = vf_pop_menu_file_list(vf); - file_util_start_editor_from_filelist(key, list, vf->dir_fd->path, vf->listview); - filelist_free(list); + file_util_start_editor_from_filelist(key, vf_pop_menu_file_list(vf), vf->dir_fd->path, vf->listview); } static void vf_pop_menu_view_cb(GtkWidget *widget, gpointer data) @@ -579,7 +576,7 @@ g_free(str_sel_mark_minus); } - vf->editmenu_fd_list = vf_selection_get_list(vf); + vf->editmenu_fd_list = vf_pop_menu_file_list(vf); submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf, vf->editmenu_fd_list); gtk_widget_set_sensitive(item, active);