From 4eec093accdc1a00142e3f83e8c42099cc915c8f Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Wed, 16 Mar 2022 21:44:30 +0800 Subject: [PATCH] use gtk_tree_view_get_n_columns instead of g_list_length (gtk_tree_view_get_columns (tree)) --- gnucash/gnome-utils/gnc-tree-view.c | 10 ++-------- .../csv-imp/assistant-csv-price-import.cpp | 4 +--- .../csv-imp/assistant-csv-trans-import.cpp | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/gnucash/gnome-utils/gnc-tree-view.c b/gnucash/gnome-utils/gnc-tree-view.c index babe8dc67f6..977323704be 100644 --- a/gnucash/gnome-utils/gnc-tree-view.c +++ b/gnucash/gnome-utils/gnc-tree-view.c @@ -2154,13 +2154,7 @@ gint gnc_tree_view_append_column (GncTreeView *view, GtkTreeViewColumn *column) { - GList *columns; - int n; - - /* There's no easy way to get this number. */ - columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view)); - n = g_list_length (columns); - g_list_free (columns); + int n = gtk_tree_view_get_n_columns (GTK_TREE_VIEW(view)); /* Ignore the initial column, the selection menu */ if (n >= 1) @@ -2177,7 +2171,7 @@ get_column_next_to (GtkTreeView *tv, GtkTreeViewColumn **col, gboolean backward) gboolean wrapped = FALSE; cols = gtk_tree_view_get_columns (tv); - g_return_val_if_fail (g_list_length (cols) > 0, FALSE); + g_return_val_if_fail (cols != NULL, FALSE); node = g_list_find (cols, *col); g_return_val_if_fail (node, FALSE); diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp index 1b1410d6e78..15c24dd1cf8 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp +++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp @@ -1646,9 +1646,7 @@ void CsvImpPriceAssist::preview_refresh_table () /* Start with counting the current number of columns (ntcols) * we have in the treeview */ - auto columns = gtk_tree_view_get_columns (treeview); - auto ntcols = g_list_length(columns); - g_list_free (columns); + auto ntcols = gtk_tree_view_get_n_columns (treeview); /* Drop redundant columns if the model has less data columns than the new model * ntcols = n° of columns in treeview (1 error column + x data columns) diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp index 7328e89ca99..07d1cb1d0e9 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp +++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp @@ -1572,9 +1572,7 @@ void CsvImpTransAssist::preview_refresh_table () /* Start with counting the current number of columns (ntcols) * we have in the treeview */ - auto columns = gtk_tree_view_get_columns (treeview); - auto ntcols = g_list_length(columns); - g_list_free (columns); + auto ntcols = gtk_tree_view_get_n_columns (treeview); /* Drop redundant columns if the model has less data columns than the new model * ntcols = n° of columns in treeview (1 error column + x data columns)