From 304fd730f48b761b71d8c2f350383e85572d0a00 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Mon, 13 Oct 2003 03:56:23 +0000 Subject: [PATCH] final tweaks git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9495 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/gncBillTerm.c | 19 +++++++++------- src/business/business-core/gncTaxTable.c | 29 ++++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/business/business-core/gncBillTerm.c b/src/business/business-core/gncBillTerm.c index 950f782f89..edd92edd95 100644 --- a/src/business/business-core/gncBillTerm.c +++ b/src/business/business-core/gncBillTerm.c @@ -62,11 +62,11 @@ struct _gncBillTerm gint cutoff; /* See src/doc/business.txt for an explanation of the following */ + /* Code that handles this is *identical* to that in gncTaxTable */ gint64 refcount; GncBillTerm * parent; /* if non-null, we are an immutable child */ GncBillTerm * child; /* if non-null, we have not changed */ gboolean invisible; - GList * children; /* list of children for disconnection */ }; @@ -224,6 +224,7 @@ static void gncBillTermFree (GncBillTerm *term) GncBillTerm * gncCloneBillTerm (GncBillTerm *from, QofBook *book) { + GList *node; GncBillTerm *term; if (!book) return NULL; @@ -241,25 +242,27 @@ gncCloneBillTerm (GncBillTerm *from, QofBook *book) term->cutoff = from->cutoff; term->invisible = from->invisible; - /** xxx I don't know what to do about refcount ... FIXME XXX */ + term->refcount = 0; - /* XXX this treats parent-child as double-linked list, not sure - * if that's true .. */ /* Make copies of parents and children. Note that this can be - * a recursive copy ... */ + * a recursive copy ... treat as doubly-linked list. */ if (from->child) { term->child = gncBillTermObtainTwin (from->child, book); term->child->parent = term; - term->child->refcount = 0; /* XXX is this right ?? */ - term->children = g_list_prepend(term->children, term->child); } - if (from->parent) { term->parent = gncBillTermObtainTwin (from->parent, book); term->parent->child = term; } + for (node=g_list_last(from->children); node; node=node->next) + { + GncBillTerm *btrm = node->data; + btrm = gncBillTermObtainTwin (btrm, book); + btrm->parent = term; + term->children = g_list_prepend(term->children, btrm); + } addObj (term); gnc_engine_generate_event (&term->inst.guid, _GNC_MOD_NAME, GNC_EVENT_CREATE); diff --git a/src/business/business-core/gncTaxTable.c b/src/business/business-core/gncTaxTable.c index 836371424a..46d7dc974c 100644 --- a/src/business/business-core/gncTaxTable.c +++ b/src/business/business-core/gncTaxTable.c @@ -53,15 +53,15 @@ struct _gncTaxTable QofInstance inst; char * name; GList * entries; + Timespec modtime; /* internal date of last modtime */ /* See src/doc/business.txt for an explanation of the following */ - Timespec modtime; /* internal date of last modtime */ + /* Code that handles this is *identical* to that in gncBillTerm */ gint64 refcount; - GncTaxTable * parent; /* if non-null, we are an immutable child */ - GncTaxTable * child; /* if non-null, we have not changed */ + GncTaxTable * parent; /* if non-null, we are an immutable child */ + GncTaxTable * child; /* if non-null, we have not changed */ gboolean invisible; - - GList * children; /* A list of children */ + GList * children; /* list of children for disconnection */ }; struct _gncTaxTableEntry @@ -255,28 +255,27 @@ gncCloneTaxTable (GncTaxTable *from, QofBook *book) table->modtime = from->modtime; table->invisible = from->invisible; - /* XXX not sure how to handle the refcount ... FIXME!! */ -#if LATER_FIXME - table->refcount = ???? -#endif + table->refcount = 0; - /* XXX this treats parent-child as double-linked list, not sure - * if that's true .. */ /* Make copies of parents and children. Note that this can be - * a recursive copy ... */ + * a recursive copy ... treat as doubly-linked list. */ if (from->child) { table->child = gncTaxTableObtainTwin (from->child, book); table->child->parent = table; - table->child->refcount = 0; /* XXX is this right ?? */ - table->children = g_list_prepend(table->children, table->child); } - if (from->parent) { table->parent = gncTaxTableObtainTwin (from->parent, book); table->parent->child = table; } + for (node=g_list_last(from->children); node; node=node->next) + { + GncTaxTable *tbl = node->data; + tbl = gncTaxTableObtainTwin (tbl, book); + tbl->parent = table; + table->children = g_list_prepend(table->children, tbl); + } /* Copy tax entries, preserving the order in the list */ table->entries = NULL;