Bug #438132: Fix warning about commodity being NULL for root account on save

This patch doesn't write the commodity, the commodity SCU, or the non-standard
SCU setting for an account that has no commodity.

Patch by Mike Alexander.
BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17866 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2009-01-31 19:49:55 +00:00
parent 297cff347a
commit e6e4a8f9b8

View File

@ -79,6 +79,7 @@ gnc_account_dom_tree_create(Account *act,
xmlNodePtr ret;
GList *lots, *n;
Account *parent;
gnc_commodity *acct_commodity;
ENTER ("(account=%p)", act);
@ -94,14 +95,18 @@ gnc_account_dom_tree_create(Account *act,
act_type_string,
xaccAccountTypeEnumAsString(xaccAccountGetType(act))));
xmlAddChild(ret, commodity_ref_to_dom_tree(act_commodity_string,
xaccAccountGetCommodity(act)));
xmlAddChild(ret, int_to_dom_tree(act_commodity_scu_string,
xaccAccountGetCommoditySCUi(act)));
acct_commodity = xaccAccountGetCommodity(act);
if (acct_commodity != NULL)
{
xmlAddChild(ret, commodity_ref_to_dom_tree(act_commodity_string,
acct_commodity));
if (xaccAccountGetNonStdSCU(act))
xmlNewChild(ret, NULL, BAD_CAST act_non_standard_scu_string, NULL);
xmlAddChild(ret, int_to_dom_tree(act_commodity_scu_string,
xaccAccountGetCommoditySCUi(act)));
if (xaccAccountGetNonStdSCU(act))
xmlNewChild(ret, NULL, BAD_CAST act_non_standard_scu_string, NULL);
}
str = xaccAccountGetCode(act);
if (str && strlen(str) > 0)