gnucash maint: [gnc-account-sel.c] prepend & reverse while building acct list

Christopher Lam clam at code.gnucash.org
Mon Apr 18 00:52:10 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/27e5515c (commit)
	from  https://github.com/Gnucash/gnucash/commit/639a88a0 (commit)



commit 27e5515c435b976b646ef302f95f470a35b75dd1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Apr 17 23:02:21 2022 +0800

    [gnc-account-sel.c] prepend & reverse while building acct list
    
    and don't use confusing double pointer

diff --git a/gnucash/gnome-utils/gnc-account-sel.c b/gnucash/gnome-utils/gnc-account-sel.c
index 389aa9a03..7178336bf 100644
--- a/gnucash/gnome-utils/gnc-account-sel.c
+++ b/gnucash/gnome-utils/gnc-account-sel.c
@@ -191,7 +191,7 @@ gnc_account_sel_set_hexpand (GNCAccountSel *gas, gboolean expand)
 typedef struct
 {
     GNCAccountSel *gas;
-    GList **outList;
+    GList *outList;
 } account_filter_data;
 
 static void
@@ -203,7 +203,7 @@ gas_populate_list (GNCAccountSel *gas)
     GtkTreeIter iter;
     GtkEntry *entry;
     gint i, active = -1;
-    GList *accts, *ptr, *filteredAccts;
+    GList *accts, *ptr;
     gchar *currentSel, *name;
 
     entry = GTK_ENTRY(gtk_bin_get_child (GTK_BIN(gas->combo)));
@@ -214,15 +214,15 @@ gas_populate_list (GNCAccountSel *gas)
     root = gnc_book_get_root_account (gnc_get_current_book ());
     accts = gnc_account_get_descendants_sorted (root);
 
-    filteredAccts   = NULL;
     atnd.gas        = gas;
-    atnd.outList    = &filteredAccts;
+    atnd.outList    = NULL;
 
     g_list_foreach (accts, gas_filter_accounts, (gpointer)&atnd);
     g_list_free (accts);
+    atnd.outList = g_list_reverse (atnd.outList);
 
     gtk_list_store_clear (gas->store);
-    for (ptr = filteredAccts, i = 0; ptr; ptr = g_list_next(ptr), i++)
+    for (ptr = atnd.outList, i = 0; ptr; ptr = g_list_next(ptr), i++)
     {
         acc = ptr->data;
         name = gnc_account_get_full_name (acc);
@@ -243,7 +243,7 @@ gas_populate_list (GNCAccountSel *gas)
 
     g_signal_handlers_unblock_by_func (gas->combo, combo_changed_cb , gas);
 
-    g_list_free (filteredAccts);
+    g_list_free (atnd.outList);
     if (currentSel)
         g_free (currentSel);
 }
@@ -280,7 +280,7 @@ gas_filter_accounts (gpointer data, gpointer user_data)
             return;
         }
     }
-    *atnd->outList = g_list_append (*atnd->outList, a);
+    atnd->outList = g_list_prepend (atnd->outList, a);
 }
 
 GtkWidget *



Summary of changes:
 gnucash/gnome-utils/gnc-account-sel.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list