Add FileDataList alias for GList with FileData elements
authorArkadiy Illarionov <[email protected]>
Sun, 25 May 2025 12:28:39 +0000 (15:28 +0300)
committerColin Clark <[email protected]>
Sun, 25 May 2025 16:35:07 +0000 (17:35 +0100)
Rename filelist_free() to file_data_list_free().
Use g_autoptr macro to simplify code a bit.

29 files changed:
src/bar-comment.cc
src/bar-gps.cc
src/bar-keywords.cc
src/bar-sort.cc
src/cache-maint.cc
src/collect-io.cc
src/collect-table.cc
src/collect.cc
src/command-line-handling.cc
src/dupe.cc
src/editors.cc
src/filedata.cc
src/filedata.h
src/filedata/filedata.cc
src/img-view.cc
src/layout-image.cc
src/pan-view/pan-folder.cc
src/pan-view/pan-view.cc
src/preferences.cc
src/search.cc
src/slideshow.cc
src/trash.cc
src/ui-utildlg.cc
src/utilops.cc
src/view-dir-list.cc
src/view-dir.cc
src/view-file/view-file-icon.cc
src/view-file/view-file-list.cc
src/view-file/view-file.cc

index 80da6f679f590bdf8577bafb5621c527bf1eba88..1a29f310dca8ef1eed3f64678c1d9699a0180587 100644 (file)
@@ -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)
index 4cc38354f0830740905d86ec8b8d2ed45edb34b1..24f926ac644e9dbacea12ac0a0c895cd28dfa8a1 100644 (file)
@@ -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);
index 63dedef1d23c5d7c13501b801ad6ec27c8bae408..73743e0bb9cc9817a24379c4e931c505ac2e9701 100644 (file)
@@ -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);
 }
 
index 1a34013e8dd0788b49e4bb4c37544d8196388f2a..951257893c6dcb63cbfa08124fd8126e7b4d65db 100644 (file)
@@ -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)
index 08ba02764c2fa8efa8c2e2a1affa4d7e4822f79c..8068822186af2edb7efa31ec63f1990cf1ef4dae 100644 (file)
@@ -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<ThumbLoader *>(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);
index 556c317449955ab306d1b088e9a5af62361bfc2e..f8621d33244ec78fb6edb660954ee15576f4df13 100644 (file)
@@ -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: */
index e49c7233c822fe4276e0e8287d75d73d015c838a..ab8e06b41474ccc5e3eeadea5d9114abc11a4ba4 100644 (file)
@@ -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<CollectTable *>(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);
                }
 }
 
index f098d2d8baabb5617fd757050638cded19fcab6b..89c231ea0187d8c908fb600163b4dd5a832a0fb1 100644 (file)
@@ -876,7 +876,6 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi
 {
        auto cw = static_cast<CollectWindow *>(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;
index f1e2674cbf801f841485d1206ec49a22848f3771..6c59f119fe7267fdd52ce3af515f60b230596a8a 100644 (file)
@@ -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<FileData *>(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);
 }
 
index 351165939eea0014471752ea3ab7c24e59f047ad..c60de4aee0f4a5e33f095808bb8a8952b1d7097e 100644 (file)
@@ -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<FileData *>(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<FileData *>(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<GList *>(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<DupeWindow *>(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<CDupeConfirmD *>(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<DupeWindow *>(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);
                }
 }
 
index cb0f9ab460b9ca7225ee50510a636a45b1ba00fb..822e0d78fc35ed32dd5d5374a433ba9aba49d4bb 100644 (file)
@@ -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<EditorFlags>(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;
                }
 
index c13b4d2c739d1868c3cf2262417dd7058760fb49..ede3ef9c762bb9c8fdf69a73db86fb304d9a56ea 100644 (file)
@@ -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);
 }
index ac6281ca46b99bc60d49247b3d2b012514d3bfa3..0d1e9dbcd11aa00dbd150579793b90973d9d9e9c 100644 (file)
@@ -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);
index cbd0aa9853437ab6d563ac10e5f5ad1250e7f82b..679a25103948e65956649765caaba236775b90b5 100644 (file)
@@ -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<GList *>(value));
+       file_data_list_free(static_cast<GList *>(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<FileData *>(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;
index 4d298fb422194558a745d4c0cb4321fe237353b6..870916b505934155c9f943cdc6623ac104764e2e 100644 (file)
@@ -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<GList *>(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<ViewWindow *>(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<CViewConfirmD *>(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);
                }
 }
index a247deea34ed7203f916f5f7e0a5439e2023df81..dd7cbab095569d7e2bf67963b3cb63a03afbde92 100644 (file)
@@ -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<GList *>(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<LayoutWindow *>(submenu_item_get_data(widget));
 
-       lw = static_cast<LayoutWindow *>(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);
                }
 }
index a933b6a9a17b3bd0f5e3013b392adea932cdda31..6cb00d4f3845b2b73fce53ad2fbbc80d4b5dea81 100644 (file)
@@ -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);
 
index 9eab3b89d27d42e7868c8cda820e0cd53b890f16..9c97b0afa09cf3c5a67e228233074cdd25de0e7f 100644 (file)
@@ -621,7 +621,7 @@ static void pan_cache_free(PanWindow *pw)
        g_list_free_full(pw->cache_list, reinterpret_cast<GDestroyNotify>(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<GList *>(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<PanWindow *>(submenu_item_get_data(widget));
 
-       pw = static_cast<PanWindow *>(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<FileData *>(list->data))->path))
                        {
                        auto fd = static_cast<FileData *>(list->data);
 
                        pan_layout_set_fd(pw, fd);
                        }
-
-               filelist_free(list);
                }
 }
 
index d3820bc7e86b2b2ecfcb22b7e35e606b3859bcc0..ef5968b822a59f2f7add460da3d3d403d1e17e1d 100644 (file)
@@ -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;
 }
 
index 7b89558418acdace2d3d2c04e4f434adf98e2e98..3e4707ba1ca8e7b5cdf75d79e23d7d544a4a841c 100644 (file)
@@ -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<SearchData *>(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<GList *>(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<SearchData *>(submenu_item_get_data(widget));
 
-       sd = static_cast<SearchData *>(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<SearchData *>(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);
                                }
                        }
                }
index 7c99a522555fd1b803805463fccd90c30fd005b6..d549bcb17a14feb2f491d29109882d1efb7406b0 100644 (file)
@@ -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);
 
index f62817d22821b57f27fe5ae9c3e04d3a48392ff0..2fa2e97abec622fd5fcac744cd6d41ed309ba2e0 100644 (file)
@@ -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;
 }
 
index a29f469f05bd047e9c0bda7f7d7362584497bd95..c2acb86082bbc5b83bab391b61c4a7158054a004 100644 (file)
@@ -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));
 }
index 655a7c5bb59067e4e87980ed6f02d50bf859fd21..cba710d51cf328e4bb4446f8aaef1cd0c38f638c 100644 (file)
@@ -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: */
index 21dcad713aa24d74e0fd8d33c833628c998e0234..52601299e82e76d6a6dc56bcd7a733e13959a02e 100644 (file)
@@ -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 *)
index a20d0c735b9c714d57539841510a03353e8b45b4..354999aa6d41e077805c18de2276d4e91221a686 100644 (file)
@@ -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)
index 06c8d99066e9e683c6720011564d2392d9f89cf1..53b4f115aa1a4f42bf808fd551c811e88a60810c 100644 (file)
@@ -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<FileData *>(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);
 
index d54cb0646d797c2295413d723c56c99d450b51cf..31a4515bea0a3c0a142259cbbe8cb10d82197c98 100644 (file)
@@ -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<FileData *>(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)
index 229c978d171435babf0fb5defb8cddd62270b1b7..d777a14e2218f4ace6729ea3e2525901e53c1252 100644 (file)
@@ -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<ViewFile *>(submenu_item_get_data(widget));
 
-       vf = static_cast<ViewFile *>(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)