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

and don't use confusing double pointer
This commit is contained in:
Christopher Lam 2022-04-17 23:02:21 +08:00
parent 639a88a05c
commit 27e5515c43

View File

@ -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 *