mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Avoid a bunch of assertion failures when the general ledger is open. The general ledger has no
account so attempts to get the balance of the register's account pass a null account pointer to functions that won't accept that. Also stop leaking a GList in the functions that get account balances. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18553 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6085758a8b
commit
5f07987bb2
@ -65,7 +65,7 @@ gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data, gboo
|
||||
SplitRegister *reg = user_data;
|
||||
Split *split;
|
||||
SRInfo *info = gnc_split_register_get_info (reg);
|
||||
gnc_numeric value = gnc_numeric_zero(), balance = gnc_numeric_zero();
|
||||
gnc_numeric balance = gnc_numeric_zero();
|
||||
Account *account = NULL;
|
||||
Transaction *trans;
|
||||
GList *node, *child;
|
||||
@ -85,12 +85,16 @@ gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data, gboo
|
||||
return gnc_numeric_zero();
|
||||
|
||||
/* Get a list of accounts for matching */
|
||||
if (subaccounts) {
|
||||
children = gnc_account_get_descendants(gnc_split_register_get_default_account(reg));
|
||||
children = g_list_append(children, gnc_split_register_get_default_account(reg));
|
||||
} else
|
||||
account = gnc_split_register_get_default_account(reg);
|
||||
account = gnc_split_register_get_default_account(reg);
|
||||
if (!account)
|
||||
/* Register has no account (perhaps general ledger) so it has no
|
||||
well defined balance, return zero. */
|
||||
return balance;
|
||||
|
||||
if (subaccounts) {
|
||||
children = gnc_account_get_descendants(account);
|
||||
children = g_list_append(children, account);
|
||||
}
|
||||
|
||||
/* Get the row number we're on, then start with the first row. */
|
||||
row = virt_loc.vcell_loc.virt_row;
|
||||
@ -125,6 +129,9 @@ gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data, gboo
|
||||
virt_loc.vcell_loc.virt_row+=i;
|
||||
}
|
||||
|
||||
if (subaccounts)
|
||||
g_list_free(children);
|
||||
|
||||
return balance;
|
||||
}
|
||||
|
||||
@ -1437,16 +1444,25 @@ static gnc_numeric
|
||||
get_trans_total_amount_subaccounts (SplitRegister *reg, Transaction *trans)
|
||||
{
|
||||
GList *children, *child;
|
||||
Account *parent;
|
||||
gnc_numeric total = gnc_numeric_zero();
|
||||
|
||||
/* Get a list of all subaccounts for matching */
|
||||
children = gnc_account_get_descendants(gnc_split_register_get_default_account(reg));
|
||||
children = g_list_append(children, gnc_split_register_get_default_account(reg));
|
||||
parent = gnc_split_register_get_default_account(reg);
|
||||
if (!parent)
|
||||
/* Register has no account, perhaps it's the general ledger. If it
|
||||
has no account then we have no way of picking out the desired splits,
|
||||
return zero. */
|
||||
return total;
|
||||
children = gnc_account_get_descendants(parent);
|
||||
children = g_list_append(children, parent);
|
||||
|
||||
for (child = children; child; child = child->next) {
|
||||
total = gnc_numeric_add_fixed(total, xaccTransGetAccountAmount(trans, child->data));
|
||||
}
|
||||
|
||||
g_list_free(children);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user