From: Arkadiy Illarionov Date: Sun, 25 May 2025 12:28:39 +0000 (+0300) Subject: Add FileDataList alias for GList with FileData elements X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6b779b04fbd9b39a73a8c8d45d3b0d5216bdee1;p=geeqie.git Add FileDataList alias for GList with FileData elements Rename filelist_free() to file_data_list_free(). Use g_autoptr macro to simplify code a bit. --- diff --git a/src/bar-comment.cc b/src/bar-comment.cc index 80da6f679..1a29f310d 100644 --- a/src/bar-comment.cc +++ b/src/bar-comment.cc @@ -109,12 +109,11 @@ static void bar_pane_comment_update(PaneCommentData *pcd) static void bar_pane_comment_set_selection(PaneCommentData *pcd, gboolean append) { - GList *list = nullptr; GList *work; g_autofree gchar *comment = text_widget_text_pull(pcd->comment_view); - list = layout_selection_list(pcd->pane.lw); + g_autoptr(FileDataList) list = layout_selection_list(pcd->pane.lw); list = file_data_process_groups_in_selection(list, FALSE, nullptr); work = list; @@ -133,8 +132,6 @@ static void bar_pane_comment_set_selection(PaneCommentData *pcd, gboolean append metadata_write_string(fd, pcd->key, comment); } } - - filelist_free(list); } static void bar_pane_comment_sel_add_cb(GtkWidget *, gpointer data) diff --git a/src/bar-gps.cc b/src/bar-gps.cc index 4cc38354f..24f926ac6 100644 --- a/src/bar-gps.cc +++ b/src/bar-gps.cc @@ -547,7 +547,7 @@ void bar_pane_gps_update(PaneGPSData *pgd) * a single, small text character the same colour as the marker background. * Use a background process in case the user selects a large number of files. */ - filelist_free(pgd->selection_list); + file_data_list_free(pgd->selection_list); if (pgd->bbox) champlain_bounding_box_free(pgd->bbox); list = layout_selection_list(pgd->pane.lw); @@ -869,7 +869,7 @@ void bar_pane_gps_destroy(gpointer data) g_idle_remove_by_data(pgd); - filelist_free(pgd->selection_list); + file_data_list_free(pgd->selection_list); if (pgd->bbox) champlain_bounding_box_free(pgd->bbox); file_data_unref(pgd->fd); diff --git a/src/bar-keywords.cc b/src/bar-keywords.cc index 63dedef1d..73743e0bb 100644 --- a/src/bar-keywords.cc +++ b/src/bar-keywords.cc @@ -428,12 +428,11 @@ gboolean bar_pane_keywords_filter_visible(GtkTreeModel *keyword_tree, GtkTreeIte void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append) { GList *keywords = nullptr; - GList *list = nullptr; GList *work; keywords = keyword_list_pull_selected(pkd->keyword_view); - list = layout_selection_list(pkd->pane.lw); + g_autoptr(FileDataList) list = layout_selection_list(pkd->pane.lw); list = file_data_process_groups_in_selection(list, FALSE, nullptr); work = list; @@ -452,7 +451,6 @@ void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append) } } - filelist_free(list); g_list_free_full(keywords, g_free); } @@ -1258,7 +1256,7 @@ void bar_pane_keywords_add_to_selected_cb(GtkWidget *, gpointer data) work = work->next; metadata_append_list(fd, KEYWORD_KEY, keywords); } - filelist_free(list); + file_data_list_free(list); g_list_free_full(keywords, g_free); } diff --git a/src/bar-sort.cc b/src/bar-sort.cc index 1a34013e8..951257893 100644 --- a/src/bar-sort.cc +++ b/src/bar-sort.cc @@ -93,13 +93,13 @@ static void bar_sort_undo_set(SortData *sd, GList *src_list, const gchar *dest); static void bar_sort_collection_list_build(GtkWidget *bookmarks) { FileData *dir_fd; - GList *list; GList *work; history_list_free_key(SORT_KEY_COLLECTIONS); bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS); dir_fd = file_data_new_dir(get_collections_dir()); + g_autoptr(FileDataList) list = nullptr; filelist_read(dir_fd, &list, nullptr); file_data_unref(dir_fd); @@ -124,8 +124,6 @@ static void bar_sort_collection_list_build(GtkWidget *bookmarks) } bookmark_list_add(bookmarks, name, fd->path); } - - filelist_free(list); } static void bar_sort_mode_sync(SortData *sd, SortModeType mode) diff --git a/src/cache-maint.cc b/src/cache-maint.cc index 08ba02764..806882218 100644 --- a/src/cache-maint.cc +++ b/src/cache-maint.cc @@ -145,7 +145,7 @@ void cache_maintain_home_close(CMData *cm) { if (cm->idle_id) g_source_remove(cm->idle_id); if (cm->gd) generic_dialog_close(cm->gd); - filelist_free(cm->list); + file_data_list_free(cm->list); g_list_free(cm->done_list); g_free(cm); } @@ -328,7 +328,7 @@ static gboolean cache_maintain_home_cb(gpointer data) } options->file_filter.disable = filter_disable; - filelist_free(list); + file_data_list_free(list); cm->list = g_list_concat(dlist, cm->list); @@ -568,10 +568,10 @@ void cache_notify_cb(FileData *fd, NotifyType type, gpointer) static void cache_manager_render_reset(CacheOpsData *cd) { - filelist_free(cd->list); + file_data_list_free(cd->list); cd->list = nullptr; - filelist_free(cd->list_dir); + file_data_list_free(cd->list_dir); cd->list_dir = nullptr; thumb_loader_free(reinterpret_cast(cd->tl)); @@ -882,7 +882,7 @@ static void cache_manager_standard_clean_close_cb(GenericDialog *, gpointer data generic_dialog_close(cd->gd); thumb_loader_std_thumb_file_validate_cancel(cd->tl); - filelist_free(cd->list); + file_data_list_free(cd->list); g_free(cd); } @@ -905,7 +905,7 @@ static void cache_manager_standard_clean_done(CacheOpsData *cd) thumb_loader_std_thumb_file_validate_cancel(cd->tl); cd->tl = nullptr; - filelist_free(cd->list); + file_data_list_free(cd->list); cd->list = nullptr; } @@ -1195,10 +1195,10 @@ static gboolean cache_manager_sim_file(CacheOpsData *cd); static void cache_manager_sim_reset(CacheOpsData *cd) { - filelist_free(cd->list); + file_data_list_free(cd->list); cd->list = nullptr; - filelist_free(cd->list_dir); + file_data_list_free(cd->list_dir); cd->list_dir = nullptr; cache_loader_free(cd->cl); diff --git a/src/collect-io.cc b/src/collect-io.cc index 556c31744..f8621d332 100644 --- a/src/collect-io.cc +++ b/src/collect-io.cc @@ -785,11 +785,11 @@ static gboolean collect_manager_process_action(CollectManagerEntry *entry, gchar static void collect_manager_refresh() { - GList *list; GList *work; FileData *dir_fd; dir_fd = file_data_new_dir(get_collections_dir()); + g_autoptr(FileDataList) list = nullptr; filelist_read(dir_fd, &list, nullptr); file_data_unref(dir_fd); @@ -836,8 +836,6 @@ static void collect_manager_refresh() collect_manager_entry_new(fd->path); } - - filelist_free(list); } static void collect_manager_process_actions(gint max) @@ -1103,7 +1101,6 @@ void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer) void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths) { FileData *dir_fd; - GList *list = nullptr; if (names_exc == nullptr && names_inc == nullptr && paths == nullptr) { @@ -1112,6 +1109,7 @@ void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths) dir_fd = file_data_new_dir((get_collections_dir())); + g_autoptr(FileDataList) list = nullptr; filelist_read(dir_fd, &list, nullptr); for (GList *work = list; work; work = work->next) @@ -1138,7 +1136,5 @@ void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths) } } } - - filelist_free(list); } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/collect-table.cc b/src/collect-table.cc index e49c7233c..ab8e06b41 100644 --- a/src/collect-table.cc +++ b/src/collect-table.cc @@ -907,18 +907,14 @@ static void collection_table_popup_remove_cb(GtkWidget *, gpointer data) static void collection_table_popup_add_file_selection_cb(GtkWidget *, gpointer data) { auto ct = static_cast(data); - GList *list; LayoutWindow *lw = get_current_layout(); if (!lw) return; - list = vf_selection_get_list(lw->vf); + g_autoptr(FileDataList) list = vf_selection_get_list(lw->vf); + if (!list) return; - if (list) - { - collection_table_add_filelist(ct, list); - filelist_free(list); - } + collection_table_add_filelist(ct, list); } static void collection_table_popup_add_collection_cb(GtkWidget *, gpointer data) @@ -987,11 +983,11 @@ static void collection_table_popup_destroy_cb(GtkWidget *, gpointer data) ct->click_info = nullptr; ct->popup = nullptr; - filelist_free(ct->drop_list); + file_data_list_free(ct->drop_list); ct->drop_list = nullptr; ct->drop_info = nullptr; - filelist_free(ct->editmenu_fd_list); + file_data_list_free(ct->editmenu_fd_list); ct->editmenu_fd_list = nullptr; } @@ -2098,8 +2094,8 @@ static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_f work = work->prev; } - filelist_free(f); - filelist_free(d); + file_data_list_free(f); + file_data_list_free(d); } static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursive) @@ -2208,7 +2204,7 @@ static void collection_table_dnd_get(GtkWidget *, GdkDragContext *, if (!list) return; uri_selection_data_set_uris_from_filelist(selection_data, list); - filelist_free(list); + file_data_list_free(list); break; } } @@ -2244,7 +2240,7 @@ static void collection_table_dnd_receive(GtkWidget *, GdkDragContext *context, gint col = -1; /* it is a move within a collection */ - filelist_free(list); + file_data_list_free(list); list = nullptr; if (!drop_info) @@ -2294,7 +2290,7 @@ static void collection_table_dnd_receive(GtkWidget *, GdkDragContext *context, if (list) { collection_table_insert_filelist(ct, list, drop_info); - filelist_free(list); + file_data_list_free(list); } } diff --git a/src/collect.cc b/src/collect.cc index f098d2d8b..89c231ea0 100644 --- a/src/collect.cc +++ b/src/collect.cc @@ -876,7 +876,6 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi { auto cw = static_cast(data); gboolean stop_signal = TRUE; - GList *list; if (event->state & GDK_CONTROL_MASK) { @@ -904,12 +903,13 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi } break; case 'L': case 'l': - list = layout_list(nullptr); + { + g_autoptr(FileDataList) list = layout_list(nullptr); if (list) { collection_table_add_filelist(cw->table, list); - filelist_free(list); } + } break; case 'C': case 'c': file_util_copy(nullptr, collection_table_selection_get_list(cw->table), nullptr, cw->window); @@ -986,17 +986,18 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi } break; case GDK_KEY_Delete: case GDK_KEY_KP_Delete: - list = g_list_copy(cw->table->selection); + { + g_autoptr(GList) list = g_list_copy(cw->table->selection); if (list) { collection_remove_by_info_list(cw->cd, list); collection_table_refresh(cw->table); - g_list_free(list); } else { collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table)); } + } break; default: stop_signal = FALSE; diff --git a/src/command-line-handling.cc b/src/command-line-handling.cc index f1e2674cb..6c59f119f 100644 --- a/src/command-line-handling.cc +++ b/src/command-line-handling.cc @@ -705,7 +705,6 @@ void gq_get_file_info(GtkApplication *, GApplicationCommandLine *app_command_lin void get_filelist(GApplicationCommandLine *app_command_line, const gchar *text, gboolean recurse) { - GList *list = nullptr; FileFormatClass format_class; FileData *dir_fd; FileData *fd; @@ -725,6 +724,7 @@ void get_filelist(GApplicationCommandLine *app_command_line, const gchar *text, dir_fd = file_data_new_dir(tilde_filename); } + g_autoptr(FileDataList) list = nullptr; if (recurse) { list = filelist_recursive(dir_fd); @@ -778,7 +778,6 @@ void get_filelist(GApplicationCommandLine *app_command_line, const gchar *text, g_application_command_line_print(app_command_line, "%s\n", out_string->str); - filelist_free(list); file_data_unref(dir_fd); } @@ -853,7 +852,7 @@ void gq_get_selection(GtkApplication *, GApplicationCommandLine *app_command_lin { if (!layout_valid(&lw_id)) return; - GList *selected = layout_selection_list(lw_id); // Keep copy to free. + g_autoptr(FileDataList) selected = layout_selection_list(lw_id); // Keep copy to free. g_autoptr(GString) out_string = g_string_new(nullptr); GList *work = selected; @@ -870,8 +869,6 @@ void gq_get_selection(GtkApplication *, GApplicationCommandLine *app_command_lin } g_application_command_line_print(app_command_line, "%s\n", out_string->str); - - filelist_free(selected); } @@ -1072,7 +1069,7 @@ void gq_selection_add(GtkApplication *, GApplicationCommandLine *app_command_lin g_autofree gchar *filename = g_path_get_basename(path); g_autofree gchar *slash_plus_filename = g_strdup_printf("%s%s", G_DIR_SEPARATOR_S, filename); - GList *file_list = layout_list(lw_id); + g_autoptr(FileDataList) file_list = layout_list(lw_id); for (GList *work = file_list; work && !fd_to_select; work = work->next) { auto fd = static_cast(work->data); @@ -1099,16 +1096,13 @@ void gq_selection_add(GtkApplication *, GApplicationCommandLine *app_command_lin g_application_command_line_print(app_command_line, "File " BOLD_ON "%s" BOLD_OFF " is not in the current folder " BOLD_ON "%s" BOLD_OFF "%c", filename, g_application_command_line_get_cwd(app_command_line), print0 ? 0 : '\n'); } - - filelist_free(file_list); } if (fd_to_select) { - GList *to_select = g_list_append(nullptr, fd_to_select); + g_autoptr(FileDataList) to_select = g_list_append(nullptr, fd_to_select); // Using the "_list" variant doesn't clear the existing selection. layout_select_list(lw_id, to_select); - filelist_free(to_select); } } @@ -1141,7 +1135,7 @@ void gq_selection_remove(GtkApplication *, GApplicationCommandLine *app_command_ fd_to_deselect = layout_image_get_fd(lw_id); if (!fd_to_deselect) { - filelist_free(selected); + file_data_list_free(selected); g_application_command_line_print(app_command_line, _("remote sent \"--selection-remove:\" with no current image\n")); return; } @@ -1197,23 +1191,22 @@ void gq_selection_remove(GtkApplication *, GApplicationCommandLine *app_command_ { // Remove first link. selected = g_list_remove_link(selected, link_to_remove); - filelist_free(link_to_remove); - link_to_remove = nullptr; } else { // Remove a subsequent link. prior_link = g_list_remove_link(prior_link, link_to_remove); - filelist_free(link_to_remove); - link_to_remove = nullptr; } + file_data_list_free(link_to_remove); + link_to_remove = nullptr; + // Re-select all but the deselected item. layout_select_none(lw_id); layout_select_list(lw_id, selected); } - filelist_free(selected); + file_data_list_free(selected); file_data_unref(fd_to_deselect); } diff --git a/src/dupe.cc b/src/dupe.cc index 351165939..c60de4aee 100644 --- a/src/dupe.cc +++ b/src/dupe.cc @@ -2117,7 +2117,7 @@ static void dupe_check_stop(DupeWindow *dw) gtk_widget_set_sensitive(dw->controls_box, TRUE); if (g_list_length(dw->add_files_queue) > 0) { - filelist_free(dw->add_files_queue); + file_data_list_free(dw->add_files_queue); } dw->add_files_queue = nullptr; dupe_window_update_progress(dw, nullptr, 0.0, FALSE); @@ -2731,14 +2731,14 @@ static void dupe_files_add(DupeWindow *dw, CollectInfo *info, dupe_files_add(dw, nullptr, static_cast(work->data), TRUE); work = work->next; } - filelist_free(f); + file_data_list_free(f); work = d; while (work) { dupe_files_add(dw, nullptr, static_cast(work->data), TRUE); work = work->next; } - filelist_free(d); + file_data_list_free(d); } } } @@ -3117,9 +3117,8 @@ static void dupe_menu_view(DupeItem *di, GtkWidget *listview, gint new_window) { if (new_window) { - GList *list = dupe_listview_get_selection(listview); + g_autoptr(FileDataList) list = dupe_listview_get_selection(listview); view_window_new_from_list(list); - filelist_free(list); } else { @@ -3177,20 +3176,16 @@ static void dupe_window_edit_selected(DupeWindow *dw, const gchar *key) static void dupe_window_collection_from_selection(DupeWindow *dw) { CollectWindow *w = collection_window_new(nullptr); - GList *list = dupe_listview_get_selection(dw->listview); + g_autoptr(FileDataList) list = dupe_listview_get_selection(dw->listview); collection_table_add_filelist(w->table, list); - filelist_free(list); } static void dupe_window_append_file_list(DupeWindow *dw, gint on_second) { - GList *list; - dw->second_drop = (dw->second_set && on_second); - list = layout_list(nullptr); + g_autoptr(FileDataList) list = layout_list(nullptr); dupe_window_add_files(dw, list, FALSE); - filelist_free(list); } /* @@ -3343,7 +3338,7 @@ static void dupe_menu_popup_destroy_cb(GtkWidget *, gpointer data) { auto editmenu_fd_list = static_cast(data); - filelist_free(editmenu_fd_list); + file_data_list_free(editmenu_fd_list); } static GList *dupe_window_get_fd_list(DupeWindow *dw) @@ -3373,10 +3368,8 @@ static void dupe_pop_menu_collections_cb(GtkWidget *widget, gpointer data) { auto *dw = static_cast(submenu_item_get_data(widget)); - GList *selection_list = dupe_listview_get_selection(dw->listview); + g_autoptr(FileDataList) selection_list = dupe_listview_get_selection(dw->listview); pop_menu_collections(selection_list, data); - - filelist_free(selection_list); } static GtkWidget *dupe_menu_popup_main(DupeWindow *dw, DupeItem *di) @@ -4755,14 +4748,13 @@ static void confirm_dir_list_add(GtkWidget *, gpointer data) work = work->next; if (isdir(fd->path)) { - GList *list; + g_autoptr(FileDataList) list = nullptr; filelist_read(fd, &list, nullptr); list = filelist_filter(list, FALSE); if (list) { dupe_window_add_files(d->dw, list, FALSE); - filelist_free(list); } } } @@ -4783,7 +4775,7 @@ static void confirm_dir_list_skip(GtkWidget *, gpointer data) static void confirm_dir_list_destroy(GtkWidget *, gpointer data) { auto d = static_cast(data); - filelist_free(d->list); + file_data_list_free(d->list); g_free(d); } @@ -4821,16 +4813,16 @@ static void dupe_dnd_data_set(GtkWidget *widget, GdkDragContext *, GtkSelectionData *selection_data, guint info, guint, gpointer) { - GList *list; - switch (info) { case TARGET_URI_LIST: case TARGET_TEXT_PLAIN: - list = dupe_listview_get_selection(widget); + { + g_autoptr(FileDataList) list = dupe_listview_get_selection(widget); if (!list) return; + uri_selection_data_set_uris_from_filelist(selection_data, list); - filelist_free(list); + } break; default: break; @@ -4844,7 +4836,6 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context, { auto dw = static_cast(data); GtkWidget *source; - GList *list = nullptr; GList *work; if (dw->add_files_queue_id > 0) @@ -4859,6 +4850,7 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context, dw->second_drop = (dw->second_set && widget == dw->second_listview); + g_autoptr(FileDataList) list = nullptr; switch (info) { case TARGET_APP_COLLECTION_MEMBER: @@ -4888,7 +4880,6 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context, if (list) { dupe_window_add_files(dw, list, FALSE); - filelist_free(list); } } diff --git a/src/editors.cc b/src/editors.cc index cb0f9ab46..822e0d78f 100644 --- a/src/editors.cc +++ b/src/editors.cc @@ -1142,7 +1142,7 @@ static EditorFlags editor_command_next_finish(EditorData *ed, gint status) if (ed->flags & EDITOR_FOR_EACH) { /* handle the first element from the list */ - GList *fd_element = ed->list; + g_autoptr(FileDataList) fd_element = ed->list; ed->list = g_list_remove_link(ed->list, fd_element); if (ed->callback) @@ -1150,14 +1150,13 @@ static EditorFlags editor_command_next_finish(EditorData *ed, gint status) cont = ed->callback(ed->list ? ed : nullptr, ed->flags, fd_element, ed->data); if (ed->stopping && cont == EDITOR_CB_CONTINUE) cont = EDITOR_CB_SKIP; } - filelist_free(fd_element); } else { /* handle whole list */ if (ed->callback) cont = ed->callback(nullptr, ed->flags, ed->list, ed->data); - filelist_free(ed->list); + file_data_list_free(ed->list); ed->list = nullptr; } @@ -1196,7 +1195,7 @@ static EditorFlags editor_command_done(EditorData *ed) { ed->flags = static_cast(ed->flags | EDITOR_ERROR_SKIPPED); if (ed->callback) ed->callback(nullptr, ed->flags, ed->list, ed->data); - filelist_free(ed->list); + file_data_list_free(ed->list); ed->list = nullptr; } diff --git a/src/filedata.cc b/src/filedata.cc index c13b4d2c7..ede3ef9c7 100644 --- a/src/filedata.cc +++ b/src/filedata.cc @@ -179,7 +179,7 @@ gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs) return FileData::FileList::read_list_lstat(dir_fd, files, dirs); } -void filelist_free(GList *list) +void file_data_list_free(FileDataList *list) { FileData::FileList::free_list(list); } diff --git a/src/filedata.h b/src/filedata.h index ac6281ca4..0d1e9dbcd 100644 --- a/src/filedata.h +++ b/src/filedata.h @@ -437,6 +437,8 @@ FileData *file_data_ref(FileData *fd); void file_data_unref(FileData *fd); #endif +using FileDataList = GList; // element is FileData + void file_data_lock(FileData *fd); void file_data_unlock(FileData *fd); void file_data_lock_list(GList *list); @@ -458,7 +460,10 @@ GList *filelist_sort_full(GList *list, SortType method, gboolean ascending, gboo gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs); gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs); -void filelist_free(GList *list); + +void file_data_list_free(FileDataList *list); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(FileDataList, file_data_list_free) + GList *filelist_copy(GList *list); GList *filelist_from_path_list(GList *list); GList *filelist_to_path_list(GList *list); diff --git a/src/filedata/filedata.cc b/src/filedata/filedata.cc index cbd0aa985..679a25103 100644 --- a/src/filedata/filedata.cc +++ b/src/filedata/filedata.cc @@ -250,7 +250,7 @@ gboolean FileData::file_data_check_changed_files(FileData *fd) } file_data_check_sidecars(sidecars); /* this will group the sidecars back together */ /* now we can release the sidecars */ - filelist_free(sidecars); + file_data_list_free(sidecars); file_data_increment_version(fd); file_data_send_notification(fd, NOTIFY_REREAD); ::file_data_unref(fd); @@ -1006,7 +1006,7 @@ void FileData::file_data_disable_grouping(FileData *fd, gboolean disable) } else if (fd->sidecar_files) { - GList *sidecar_files = filelist_copy(fd->sidecar_files); + g_autoptr(FileDataList) sidecar_files = filelist_copy(fd->sidecar_files); GList *work = sidecar_files; while (work) { @@ -1016,7 +1016,6 @@ void FileData::file_data_disable_grouping(FileData *fd, gboolean disable) file_data_send_notification(sfd, NOTIFY_GROUPING); } file_data_check_sidecars(sidecar_files); /* this will group the sidecars back together */ - filelist_free(sidecar_files); } else { @@ -1110,7 +1109,7 @@ void FileData::file_data_basename_hash_insert_cb(gpointer fd, gpointer basename_ void FileData::file_data_basename_hash_remove_list(gpointer, gpointer value, gpointer) { - filelist_free(static_cast(value)); + file_data_list_free(static_cast(value)); } void FileData::file_data_basename_hash_free(GHashTable *basename_hash) @@ -1145,7 +1144,7 @@ FileData *FileData::file_data_new_group(const gchar *path_utf8, FileDataContext g_autofree gchar *dir = remove_level_from_path(path_utf8); - GList *files; + g_autoptr(FileDataList) files = nullptr; FileList::read_list_real(dir, &files, nullptr, TRUE); auto *fd = static_cast(g_hash_table_lookup(context->file_data_pool, path_utf8)); @@ -1158,7 +1157,6 @@ FileData *FileData::file_data_new_group(const gchar *path_utf8, FileDataContext ::file_data_ref(fd); } - filelist_free(files); return fd; } @@ -2579,7 +2577,7 @@ GList *FileData::file_data_process_groups_in_selection(GList *list, gboolean ung } } - filelist_free(list); + file_data_list_free(list); out = g_list_reverse(out); return out; diff --git a/src/img-view.cc b/src/img-view.cc index 4d298fb42..870916b50 100644 --- a/src/img-view.cc +++ b/src/img-view.cc @@ -169,7 +169,7 @@ static ImageWindow *view_window_active_image(ViewWindow *vw) static void view_window_set_list(ViewWindow *vw, GList *list) { - filelist_free(vw->list); + file_data_list_free(vw->list); vw->list = nullptr; vw->list_pointer = nullptr; @@ -857,7 +857,7 @@ static void view_window_destroy_cb(GtkWidget *, gpointer data) view_slideshow_stop(vw); fullscreen_stop(vw->fs); - filelist_free(vw->list); + file_data_list_free(vw->list); file_data_unregister_notify_func(view_window_notify_cb, vw); @@ -1041,7 +1041,7 @@ void view_window_new(FileData *fd) list = filelist_sort_path(list); list = filelist_filter(list, FALSE); real_view_window_new(nullptr, list, nullptr, nullptr); - filelist_free(list); + file_data_list_free(list); } else { @@ -1321,7 +1321,7 @@ static void view_popup_menu_destroy_cb(GtkWidget *, gpointer data) { auto editmenu_fd_list = static_cast(data); - filelist_free(editmenu_fd_list); + file_data_list_free(editmenu_fd_list); } static GList *view_window_get_fd_list(ViewWindow *vw) @@ -1350,15 +1350,13 @@ static void image_pop_menu_collections_cb(GtkWidget *widget, gpointer data) ViewWindow *vw; ImageWindow *imd; FileData *fd; - GList *selection_list = nullptr; vw = static_cast(submenu_item_get_data(widget)); imd = view_window_active_image(vw); fd = image_get_fd(imd); - selection_list = g_list_append(selection_list, fd); - pop_menu_collections(selection_list, data); - filelist_free(selection_list); + g_autoptr(FileDataList) selection_list = g_list_append(nullptr, fd); + pop_menu_collections(selection_list, data); } static GtkWidget *view_popup_menu(ViewWindow *vw) @@ -1550,7 +1548,7 @@ static void view_dir_list_skip(GtkWidget *, gpointer data) static void view_dir_list_destroy(GtkWidget *, gpointer data) { auto d = static_cast(data); - filelist_free(d->list); + file_data_list_free(d->list); g_free(d); } @@ -1599,7 +1597,7 @@ static void view_window_get_dnd_data(GtkWidget *, GdkDragContext *context, if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) { CollectionData *source; - GList *list; + g_autoptr(FileDataList) list = nullptr; GList *info_list; if (info == TARGET_URI_LIST) @@ -1659,7 +1657,7 @@ static void view_window_get_dnd_data(GtkWidget *, GdkDragContext *context, } } } - filelist_free(list); + g_list_free(info_list); } } diff --git a/src/layout-image.cc b/src/layout-image.cc index a247deea3..dd7cbab09 100644 --- a/src/layout-image.cc +++ b/src/layout-image.cc @@ -211,7 +211,7 @@ void layout_image_slideshow_start_from_list(LayoutWindow *lw, GList *list) if (lw->slideshow || !list) { - filelist_free(list); + file_data_list_free(list); return; } @@ -735,7 +735,7 @@ static void layout_image_popup_menu_destroy_cb(GtkWidget *, gpointer data) { auto editmenu_fd_list = static_cast(data); - filelist_free(editmenu_fd_list); + file_data_list_free(editmenu_fd_list); } static GList *layout_image_get_fd_list(LayoutWindow *lw) @@ -764,14 +764,10 @@ static GList *layout_image_get_fd_list(LayoutWindow *lw) */ static void layout_pop_menu_collections_cb(GtkWidget *widget, gpointer data) { - LayoutWindow *lw; - GList *selection_list = nullptr; + auto *lw = static_cast(submenu_item_get_data(widget)); - lw = static_cast(submenu_item_get_data(widget)); - selection_list = g_list_append(selection_list, layout_image_get_fd(lw)); + g_autoptr(FileDataList) selection_list = g_list_append(nullptr, layout_image_get_fd(lw)); pop_menu_collections(selection_list, data); - - filelist_free(selection_list); } static void li_pop_menu_selectable_toolbars_toggle_cb(GtkWidget *, gpointer) @@ -944,7 +940,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *, else if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER) { CollectionData *source; - GList *list; + g_autoptr(FileDataList) list = nullptr; GList *info_list; if (info == TARGET_URI_LIST) @@ -996,7 +992,6 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *, } } - filelist_free(list); g_list_free(info_list); } } diff --git a/src/pan-view/pan-folder.cc b/src/pan-view/pan-folder.cc index a933b6a9a..6cb00d4f3 100644 --- a/src/pan-view/pan-folder.cc +++ b/src/pan-view/pan-folder.cc @@ -326,7 +326,7 @@ static FlowerGroup *pan_flower_group(PanWindow *pw, FileData *dir_fd, gint x, gi } g_list_free(f); - filelist_free(d); + file_data_list_free(d); return group; } @@ -433,7 +433,7 @@ static void pan_folder_tree_path(PanWindow *pw, FileData *dir_fd, } } - filelist_free(d); + file_data_list_free(d); pan_item_size_by_item(parent, pi_box, PAN_BOX_BORDER); diff --git a/src/pan-view/pan-view.cc b/src/pan-view/pan-view.cc index 9eab3b89d..9c97b0afa 100644 --- a/src/pan-view/pan-view.cc +++ b/src/pan-view/pan-view.cc @@ -621,7 +621,7 @@ static void pan_cache_free(PanWindow *pw) g_list_free_full(pw->cache_list, reinterpret_cast(pan_cache_data_free)); pw->cache_list = nullptr; - filelist_free(pw->cache_todo); + file_data_list_free(pw->cache_todo); pw->cache_todo = nullptr; pw->cache_count = 0; @@ -2279,7 +2279,7 @@ static void pan_popup_menu_destroy_cb(GtkWidget *, gpointer data) { auto editmenu_fd_list = static_cast(data); - filelist_free(editmenu_fd_list); + file_data_list_free(editmenu_fd_list); } static void pan_play_cb(GtkWidget *, gpointer data) @@ -2308,14 +2308,10 @@ static GList *pan_view_get_fd_list(PanWindow *pw) */ static void pan_pop_menu_collections_cb(GtkWidget *widget, gpointer data) { - PanWindow *pw; - GList *selection_list = nullptr; + auto *pw = static_cast(submenu_item_get_data(widget)); - pw = static_cast(submenu_item_get_data(widget)); - selection_list = g_list_append(selection_list, pan_menu_click_fd(pw)); + g_autoptr(FileDataList) selection_list = g_list_append(nullptr, pan_menu_click_fd(pw)); pop_menu_collections(selection_list, data); - - filelist_free(selection_list); } static GtkWidget *pan_popup_menu(PanWindow *pw) @@ -2465,17 +2461,13 @@ static void pan_window_get_dnd_data(GtkWidget *, GdkDragContext *context, if (info == TARGET_URI_LIST) { - GList *list; - - list = uri_filelist_from_gtk_selection_data(selection_data); + g_autoptr(FileDataList) list = uri_filelist_from_gtk_selection_data(selection_data); if (list && isdir((static_cast(list->data))->path)) { auto fd = static_cast(list->data); pan_layout_set_fd(pw, fd); } - - filelist_free(list); } } diff --git a/src/preferences.cc b/src/preferences.cc index d3820bc7e..ef5968b82 100644 --- a/src/preferences.cc +++ b/src/preferences.cc @@ -3002,10 +3002,10 @@ static void keywords_find_folder(KeywordFindData *kfd, FileData *dir_fd) static void keywords_find_reset(KeywordFindData *kfd) { - filelist_free(kfd->list); + file_data_list_free(kfd->list); kfd->list = nullptr; - filelist_free(kfd->list_dir); + file_data_list_free(kfd->list_dir); kfd->list_dir = nullptr; } diff --git a/src/search.cc b/src/search.cc index 7b8955841..3e4707ba1 100644 --- a/src/search.cc +++ b/src/search.cc @@ -858,12 +858,10 @@ static void search_result_edit_selected(SearchData *sd, const gchar *key) static void search_result_collection_from_selection(SearchData *sd) { CollectWindow *w; - GList *list; - list = search_result_selection_list(sd); + g_autoptr(FileDataList) list = search_result_selection_list(sd); w = collection_window_new(nullptr); collection_table_add_filelist(w->table, list); - filelist_free(list); } static gboolean search_result_update_idle_cb(gpointer data) @@ -1073,11 +1071,9 @@ static void sr_menu_view_cb(GtkWidget *, gpointer data) static void sr_menu_viewnew_cb(GtkWidget *, gpointer data) { auto sd = static_cast(data); - GList *list; - list = search_result_selection_list(sd); + g_autoptr(FileDataList) list = search_result_selection_list(sd); view_window_new_from_list(list); - filelist_free(list); } static void sr_menu_select_all_cb(GtkWidget *, gpointer data) @@ -1174,7 +1170,7 @@ static void search_result_menu_destroy_cb(GtkWidget *, gpointer data) { auto editmenu_fd_list = static_cast(data); - filelist_free(editmenu_fd_list); + file_data_list_free(editmenu_fd_list); } /** @@ -1182,18 +1178,13 @@ static void search_result_menu_destroy_cb(GtkWidget *, gpointer data) * @param[in] widget * @param[in] data Index to the collection list menu item selected, or -1 for new collection * - * */ static void search_pop_menu_collections_cb(GtkWidget *widget, gpointer data) { - SearchData *sd; - GList *selection_list; + auto *sd = static_cast(submenu_item_get_data(widget)); - sd = static_cast(submenu_item_get_data(widget)); - selection_list = search_result_selection_list(sd); + g_autoptr(FileDataList) selection_list = search_result_selection_list(sd); pop_menu_collections(selection_list, data); - - filelist_free(selection_list); } static GtkWidget *search_result_menu(SearchData *sd, gboolean on_row, gboolean empty) @@ -1480,11 +1471,8 @@ static gboolean search_result_keypress_cb(GtkWidget *widget, GdkEventKey *event, break; case 'V': case 'v': { - GList *list; - - list = search_result_selection_list(sd); + g_autoptr(FileDataList) list = search_result_selection_list(sd); view_window_new_from_list(list); - filelist_free(list); } break; case GDK_KEY_Delete: case GDK_KEY_KP_Delete: @@ -1562,13 +1550,11 @@ static void search_dnd_data_set(GtkWidget *, GdkDragContext *, guint, gpointer data) { auto sd = static_cast(data); - GList *list; - list = search_result_selection_list(sd); + g_autoptr(FileDataList) list = search_result_selection_list(sd); if (!list) return; uri_selection_data_set_uris_from_filelist(selection_data, list); - filelist_free(list); } static void search_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) @@ -1775,13 +1761,13 @@ static void search_stop(SearchData *sd) search_buffer_flush(sd); - filelist_free(sd->search_folder_list); + file_data_list_free(sd->search_folder_list); sd->search_folder_list = nullptr; g_list_free(sd->search_done_list); sd->search_done_list = nullptr; - filelist_free(sd->search_file_list); + file_data_list_free(sd->search_file_list); sd->search_file_list = nullptr; sd->match_broken_enable = FALSE; @@ -2427,7 +2413,7 @@ static gboolean search_step_cb(gpointer data) } else { - filelist_free(dlist); + file_data_list_free(dlist); } } } diff --git a/src/slideshow.cc b/src/slideshow.cc index 7c99a5225..d549bcb17 100644 --- a/src/slideshow.cc +++ b/src/slideshow.cc @@ -43,7 +43,7 @@ void slideshow_free(SlideShowData *ss) if (ss->stop_func) ss->stop_func(ss, ss->stop_data); - if (ss->filelist) filelist_free(ss->filelist); + if (ss->filelist) file_data_list_free(ss->filelist); if (ss->cd) collection_unref(ss->cd); file_data_unref(ss->dir_fd); diff --git a/src/trash.cc b/src/trash.cc index f62817d22..2fa2e97ab 100644 --- a/src/trash.cc +++ b/src/trash.cc @@ -48,13 +48,13 @@ static gint file_util_safe_number(gint64 free_space) { gint n = 0; gint64 total = 0; - GList *list; GList *work; gboolean sorted = FALSE; gboolean warned = FALSE; FileData *dir_fd; dir_fd = file_data_new_dir(options->file_ops.safe_delete_path); + g_autoptr(FileDataList) list = nullptr; if (!filelist_read(dir_fd, &list, nullptr)) { file_data_unref(dir_fd); @@ -103,8 +103,6 @@ static gint file_util_safe_number(gint64 free_space) file_data_unref(fd); } - filelist_free(list); - return n; } diff --git a/src/ui-utildlg.cc b/src/ui-utildlg.cc index a29f469f0..c2acb8608 100644 --- a/src/ui-utildlg.cc +++ b/src/ui-utildlg.cc @@ -607,7 +607,7 @@ void file_dialog_close(FileDialog *fdlg) { file_data_unref(fdlg->source_fd); g_free(fdlg->dest_path); - if (fdlg->source_list) filelist_free(fdlg->source_list); + if (fdlg->source_list) file_data_list_free(fdlg->source_list); generic_dialog_close(GENERIC_DIALOG(fdlg)); } diff --git a/src/utilops.cc b/src/utilops.cc index 655a7c5bb..cba710d51 100644 --- a/src/utilops.cc +++ b/src/utilops.cc @@ -525,8 +525,8 @@ static void file_util_data_free(UtilityData *ud) if (ud->perform_idle_id) g_source_remove(ud->perform_idle_id); file_data_unref(ud->dir_fd); - filelist_free(ud->content_list); - filelist_free(ud->flist); + file_data_list_free(ud->content_list); + file_data_list_free(ud->flist); if (ud->gd) generic_dialog_close(ud->gd); @@ -2145,7 +2145,6 @@ static void file_util_mark_ungrouped_files(GList *work) static void file_util_delete_full(FileData *source_fd, GList *flist, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data) { UtilityData *ud; - GList *ungrouped = nullptr; gchar *message; if (source_fd) @@ -2153,19 +2152,18 @@ static void file_util_delete_full(FileData *source_fd, GList *flist, GtkWidget * if (!flist) return; + g_autoptr(FileDataList) ungrouped = nullptr; flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped); if (!file_data_sc_add_ci_delete_list(flist)) { file_util_warn_op_in_progress(_("File deletion failed")); file_data_disable_grouping_list(ungrouped, FALSE); - filelist_free(flist); - filelist_free(ungrouped); + file_data_list_free(flist); return; } file_util_mark_ungrouped_files(ungrouped); - filelist_free(ungrouped); ud = file_util_data_new(UtilityType::DELETE); @@ -2228,7 +2226,7 @@ static void file_util_write_metadata_full(FileData *source_fd, GList *flist, Gtk if (!file_data_add_ci_write_metadata_list(flist)) { file_util_warn_op_in_progress(_("Can't write metadata")); - filelist_free(flist); + file_data_list_free(flist); return; } @@ -2262,26 +2260,24 @@ static void file_util_write_metadata_full(FileData *source_fd, GList *flist, Gtk static void file_util_move_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *ungrouped = nullptr; if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); if (!flist) return; + g_autoptr(FileDataList) ungrouped = nullptr; flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped); if (!file_data_sc_add_ci_move_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Move failed")); file_data_disable_grouping_list(ungrouped, FALSE); - filelist_free(flist); - filelist_free(ungrouped); + file_data_list_free(flist); return; } file_util_mark_ungrouped_files(ungrouped); - filelist_free(ungrouped); ud = file_util_data_new(UtilityType::MOVE); @@ -2309,7 +2305,6 @@ static void file_util_move_full(FileData *source_fd, GList *flist, const gchar * static void file_util_copy_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *ungrouped = nullptr; if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); @@ -2319,19 +2314,18 @@ static void file_util_copy_full(FileData *source_fd, GList *flist, const gchar * if (file_util_write_metadata_first(UtilityType::COPY, phase, flist, dest_path, nullptr, parent)) return; + g_autoptr(FileDataList) ungrouped = nullptr; flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped); if (!file_data_sc_add_ci_copy_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Copy failed")); file_data_disable_grouping_list(ungrouped, FALSE); - filelist_free(flist); - filelist_free(ungrouped); + file_data_list_free(flist); return; } file_util_mark_ungrouped_files(ungrouped); - filelist_free(ungrouped); ud = file_util_data_new(UtilityType::COPY); @@ -2359,26 +2353,24 @@ static void file_util_copy_full(FileData *source_fd, GList *flist, const gchar * static void file_util_rename_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; - GList *ungrouped = nullptr; if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); if (!flist) return; + g_autoptr(FileDataList) ungrouped = nullptr; flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped); if (!file_data_sc_add_ci_rename_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Rename failed")); file_data_disable_grouping_list(ungrouped, FALSE); - filelist_free(flist); - filelist_free(ungrouped); + file_data_list_free(flist); return; } file_util_mark_ungrouped_files(ungrouped); - filelist_free(ungrouped); ud = file_util_data_new(UtilityType::RENAME); @@ -2405,7 +2397,6 @@ static void file_util_rename_full(FileData *source_fd, GList *flist, const gchar 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 *ungrouped = nullptr; if (editor_no_param(key)) { @@ -2423,7 +2414,7 @@ static void file_util_start_editor_full(const gchar *key, FileData *source_fd, G /* just start the editor, don't care about files */ start_editor(key, working_directory); - filelist_free(flist); + file_data_list_free(flist); return; } @@ -2442,19 +2433,18 @@ static void file_util_start_editor_full(const gchar *key, FileData *source_fd, G if (file_util_write_metadata_first(UtilityType::FILTER, phase, flist, dest_path, key, parent)) return; + g_autoptr(FileDataList) ungrouped = nullptr; flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped); if (!file_data_sc_add_ci_unspecified_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Can't run external editor")); file_data_disable_grouping_list(ungrouped, FALSE); - filelist_free(flist); - filelist_free(ungrouped); + file_data_list_free(flist); return; } file_util_mark_ungrouped_files(ungrouped); - filelist_free(ungrouped); if (editor_is_filter(key)) ud = file_util_data_new(UtilityType::FILTER); @@ -2514,8 +2504,6 @@ static GList *file_util_delete_dir_remaining_folders(GList *dlist) static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, gint level) { - GList *dlist; - GList *flist; GList *work; DEBUG_1("deltree into: %s", fd->path); @@ -2525,13 +2513,15 @@ static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, g { log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH); // ud->fail_fd = fd - return 0; + return FALSE; } + g_autoptr(FileDataList) dlist = nullptr; + g_autoptr(FileDataList) flist = nullptr; if (!filelist_read_lstat(fd, &flist, &dlist)) { // ud->fail_fd = fd - return 0; + return FALSE; } gboolean ok = file_data_sc_add_ci_delete(fd); @@ -2570,9 +2560,6 @@ static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, g // ud->fail_fd = fd } - filelist_free(dlist); - filelist_free(flist); - DEBUG_1("deltree done: %s", fd->path); return ok; @@ -2724,20 +2711,20 @@ static void file_util_delete_dir_full(FileData *fd, GtkWidget *parent, UtilityPh } else { - filelist_free(dlist); + file_data_list_free(dlist); file_util_dialog_run(ud); return; } } g_list_free(rlist); - filelist_free(dlist); - filelist_free(flist); + file_data_list_free(dlist); + file_data_list_free(flist); } static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd) { - GList *dlist; + g_autoptr(FileDataList) dlist = nullptr; GList *flist; GList *work; @@ -2746,7 +2733,7 @@ static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd) if (!filelist_read_lstat(fd, &flist, &dlist)) { // ud->fail_fd = fd - return 0; + return FALSE; } ud->content_list = g_list_concat(flist, ud->content_list); @@ -2763,8 +2750,6 @@ static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd) ok = file_util_rename_dir_scan(ud, lfd); } - filelist_free(dlist); - return ok; } @@ -2885,7 +2870,7 @@ static void file_util_write_metadata_first_done(gboolean success, const gchar *, } /* the operation was cancelled */ - filelist_free(dd->flist); + file_data_list_free(dd->flist); g_free(dd->dest_path); g_free(dd->editor_key); g_free(dd); @@ -2906,7 +2891,7 @@ static gboolean file_util_write_metadata_first(UtilityType type, UtilityPhase ph if (fd->change) { - filelist_free(unsaved); + file_data_list_free(unsaved); return FALSE; /* another op. in progress, let the caller handle it */ } @@ -3242,7 +3227,7 @@ void file_util_path_list_to_clipboard(GList *fd_list, gboolean quoted, Clipboard path_list_to_clipboard(get_path_list(fd_list), quoted, action, GDK_SELECTION_CLIPBOARD); } - filelist_free(fd_list); + file_data_list_free(fd_list); } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/view-dir-list.cc b/src/view-dir-list.cc index 21dcad713..52601299e 100644 --- a/src/view-dir-list.cc +++ b/src/view-dir-list.cc @@ -306,7 +306,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear) vd->click_fd = nullptr; vd->drop_fd = nullptr; - filelist_free(old_list); + file_data_list_free(old_list); return ret; } @@ -428,7 +428,7 @@ void vdlist_destroy_cb(GtkWidget *, gpointer data) vd_dnd_drop_scroll_cancel(vd); widget_auto_scroll_stop(vd->view); - filelist_free(VDLIST(vd)->list); + file_data_list_free(VDLIST(vd)->list); } ViewDir *vdlist_new(ViewDir *vd, FileData *) diff --git a/src/view-dir.cc b/src/view-dir.cc index a20d0c735..354999aa6 100644 --- a/src/view-dir.cc +++ b/src/view-dir.cc @@ -174,7 +174,7 @@ static void vd_destroy_cb(GtkWidget *widget, gpointer data) } folder_icons_free(vd->pf); - filelist_free(vd->drop_list); + file_data_list_free(vd->drop_list); file_data_unref(vd->dir_fd); g_free(vd->info); @@ -384,7 +384,7 @@ void vd_popup_destroy_cb(GtkWidget *, gpointer data) vd->popup = nullptr; vd_color_set(vd, vd->drop_fd, FALSE); - filelist_free(vd->drop_list); + file_data_list_free(vd->drop_list); vd->drop_list = nullptr; vd->drop_fd = nullptr; } @@ -524,10 +524,11 @@ static void vd_pop_menu_slide_rec_cb(GtkWidget *, gpointer data) static void vd_pop_menu_dupe(ViewDir *vd, gint recursive) { DupeWindow *dw; - GList *list = nullptr; if (!vd->click_fd) return; + g_autoptr(FileDataList) list = nullptr; + if (recursive) { list = g_list_append(list, file_data_ref(vd->click_fd)); @@ -540,8 +541,6 @@ static void vd_pop_menu_dupe(ViewDir *vd, gint recursive) dw = dupe_window_new(); dupe_window_add_files(dw, list, recursive); - - filelist_free(list); } static void vd_pop_menu_dupe_cb(GtkWidget *, gpointer data) diff --git a/src/view-file/view-file-icon.cc b/src/view-file/view-file-icon.cc index 06c8d9906..53b4f115a 100644 --- a/src/view-file/view-file-icon.cc +++ b/src/view-file/view-file-icon.cc @@ -833,18 +833,15 @@ void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode) { - GList *slist; - g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); - slist = vficon_selection_get_list(vf); + g_autoptr(FileDataList) slist = vficon_selection_get_list(vf); for (GList *work = slist; work; work = work->next) { auto fd = static_cast(work->data); file_data_selection_to_mark(fd, mark, mode); } - filelist_free(slist); } static void vficon_select_closest(ViewFile *vf, FileData *sel_fd) @@ -1863,7 +1860,7 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position) g_list_free(reversed_old_selected); } - filelist_free(new_filelist); + file_data_list_free(new_filelist); vficon_populate(vf, TRUE, keep_position); diff --git a/src/view-file/view-file-list.cc b/src/view-file/view-file-list.cc index d54cb0646..31a4515be 100644 --- a/src/view-file/view-file-list.cc +++ b/src/view-file/view-file-list.cc @@ -292,7 +292,7 @@ void vflist_pop_menu_rename_cb(ViewFile *vf) GtkTreeModel *store; GtkTreeIter iter; - filelist_free(list); + file_data_list_free(list); store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); if (vflist_find_row(vf, vf->click_fd, &iter) >= 0) @@ -1670,7 +1670,7 @@ static void vflist_populate_view(ViewFile *vf, gboolean force) vflist_select_closest(vf, static_cast(selected->data)); } - filelist_free(selected); + file_data_list_free(selected); vf_send_update(vf); vf_thumb_update(vf); @@ -1726,7 +1726,7 @@ gboolean vflist_refresh(ViewFile *vf) DEBUG_1("%s vflist_refresh: free filelist", get_exec_time()); - filelist_free(old_list); + file_data_list_free(old_list); DEBUG_1("%s vflist_refresh: done", get_exec_time()); return ret; @@ -1881,7 +1881,7 @@ gboolean vflist_set_fd(ViewFile *vf, FileData *dir_fd) /* force complete reload */ vflist_store_clear(vf, TRUE); - filelist_free(vf->list); + file_data_list_free(vf->list); vf->list = nullptr; ret = vflist_refresh(vf); @@ -1898,7 +1898,7 @@ void vflist_destroy_cb(ViewFile *vf) vf_thumb_stop(vf); vf_star_stop(vf); - filelist_free(vf->list); + file_data_list_free(vf->list); } ViewFile *vflist_new(ViewFile *vf) diff --git a/src/view-file/view-file.cc b/src/view-file/view-file.cc index 229c978d1..d777a14e2 100644 --- a/src/view-file/view-file.cc +++ b/src/view-file/view-file.cc @@ -334,7 +334,7 @@ static void vf_dnd_get(GtkWidget *, GdkDragContext *, if (!vf->click_fd) return; - GList *list = nullptr; + g_autoptr(FileDataList) list = nullptr; if (vf_is_selected(vf, vf->click_fd)) { @@ -348,7 +348,6 @@ static void vf_dnd_get(GtkWidget *, GdkDragContext *, if (!list) return; uri_selection_data_set_uris_from_filelist(selection_data, list); - filelist_free(list); } static void vf_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) @@ -475,11 +474,8 @@ static void vf_pop_menu_view_cb(GtkWidget *, gpointer data) if (vf_is_selected(vf, vf->click_fd)) { - GList *list; - - list = vf_selection_get_list(vf); + g_autoptr(FileDataList) list = vf_selection_get_list(vf); view_window_new_from_list(list); - filelist_free(list); } else { @@ -719,7 +715,7 @@ static void vf_popup_destroy_cb(GtkWidget *, gpointer data) vf->click_fd = nullptr; vf->popup = nullptr; - filelist_free(vf->editmenu_fd_list); + file_data_list_free(vf->editmenu_fd_list); vf->editmenu_fd_list = nullptr; } @@ -728,18 +724,13 @@ static void vf_popup_destroy_cb(GtkWidget *, gpointer data) * @param[in] widget * @param[in] data Index to the collection list menu item selected, or -1 for new collection * - * */ static void vf_pop_menu_collections_cb(GtkWidget *widget, gpointer data) { - ViewFile *vf; - GList *selection_list; + auto *vf = static_cast(submenu_item_get_data(widget)); - vf = static_cast(submenu_item_get_data(widget)); - selection_list = vf_selection_get_list(vf); + g_autoptr(FileDataList) selection_list = vf_selection_get_list(vf); pop_menu_collections(selection_list, data); - - filelist_free(selection_list); } static void vf_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data)