bug fix newly added book-closing code

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6186 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas
2001-12-04 06:46:02 +00:00
parent f156eef1de
commit 03e9c30c0e
2 changed files with 30 additions and 6 deletions
+19 -6
View File
@@ -60,6 +60,7 @@ xaccInitializeAccountGroup (AccountGroup *grp, GNCBook *book)
grp->accounts = NULL;
grp->book = book;
grp->editlevel = 0;
}
/********************************************************************\
@@ -145,6 +146,7 @@ xaccAccountGroupBeginEdit (AccountGroup *grp)
GList *node;
if (!grp) return;
grp->editlevel++;
for (node = grp->accounts; node; node = node->next)
{
@@ -172,6 +174,7 @@ xaccAccountGroupCommitEdit (AccountGroup *grp)
xaccAccountGroupCommitEdit (account->children);
xaccAccountCommitEdit (account);
}
grp->editlevel--;
}
/********************************************************************\
@@ -363,7 +366,7 @@ xaccGroupGetNumSubAccounts (AccountGroup *grp)
\********************************************************************/
static void
xaccPrependAccounts (AccountGroup *grp, GList **accounts_p)
xaccAppendAccounts (AccountGroup *grp, GList **accounts_p)
{
GList *node;
@@ -373,22 +376,22 @@ xaccPrependAccounts (AccountGroup *grp, GList **accounts_p)
{
Account *account = node->data;
*accounts_p = g_list_prepend (*accounts_p, account);
*accounts_p = g_list_append (*accounts_p, account);
xaccPrependAccounts (account->children, accounts_p);
xaccApppendAccounts (account->children, accounts_p);
}
}
GList *
AccountList *
xaccGroupGetSubAccounts (AccountGroup *grp)
{
GList *accounts = NULL;
if (!grp) return NULL;
xaccPrependAccounts (grp, &accounts);
xaccAppendAccounts (grp, &accounts);
return g_list_reverse (accounts);
return accounts;
}
AccountList *
@@ -789,6 +792,7 @@ xaccGroupConcatGroup (AccountGroup *togrp, AccountGroup *fromgrp)
void
xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
{
int i;
GList *node;
if (!to || !from) return;
if (!from->accounts || !to->book) return;
@@ -811,6 +815,15 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
xaccGroupCopyGroup (to_acc->children, from_acc->children);
}
xaccAccountCommitEdit (to_acc);
/* make sure that we have a symmetric, uniform number of
* begin-edits, so that subsequent GroupCommitEdit's
* balance out. */
for (i=0; i<to->editlevel; i++)
{
xaccAccountBeginEdit (to_acc);
xaccAccountGroupBeginEdit (to_acc->children);
}
}
}
+11
View File
@@ -56,8 +56,19 @@ struct account_group_s
AccountList *accounts; /* list of account pointers */
GNCBook *book; /* The book which this group belongs to */
/* keep track of nesting level of begin/end edit calls */
gint32 editlevel;
};
/*
* The xaccGroupSetBook() routine merely sets the 'book' member
* in the structure above. It does not actually invoke the
* backend to physically move the group from one book to another,
* and thus is a 'dangerous' routine, because it may not have
* the effect that the user was intending (of actually moving
* the book).
*/
void xaccGroupSetBook (AccountGroup *group, GNCBook *book);