Skip to content

Commit

Permalink
Convert Split from QofEntity to QofInstance.
Browse files Browse the repository at this point in the history
   Let QofInstance manage the book pointer and kvp frame instead of Split 
   managing its own.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13131 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
spot committed Feb 6, 2006
1 parent fccb17f commit c1ef3fd
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/backend/postgres/txn.c
Expand Up @@ -176,7 +176,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
{
Split *s = split_node->data;

if (s && guid_equal (&s->entity.guid, &dti->guid))
if (s && guid_equal (&s->inst.entity.guid, &dti->guid))
{
pgendStoreAuditSplit (be, s, SQL_DELETE);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Account.c
Expand Up @@ -793,7 +793,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)

if (!acc || !split || split->acc == acc) return;
/* check for book mix-up */
g_return_if_fail (acc->inst.book == split->book);
g_return_if_fail (acc->inst.book == split->inst.book);

trans = xaccSplitGetParent (split);
ENTER ("(acc=%p, trans=%p, split=%p)", acc, trans, split);
Expand Down
16 changes: 8 additions & 8 deletions src/engine/Period.c
Expand Up @@ -100,8 +100,8 @@ gnc_book_insert_trans_clobber (QofBook *book, Transaction *trans)
Split *s = node->data;

/* move the split into the new book ... */
s->book = book;
qof_collection_insert_entity(col, &s->entity);
s->inst.book = book;
qof_collection_insert_entity(col, &s->inst.entity);

/* find the twin account, and re-parent to that. */
twin = xaccAccountLookupTwin (s->acc, book);
Expand Down Expand Up @@ -161,10 +161,10 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
Split *s = node->data;

/* Move the splits over (only if they haven't already been moved). */
if (s->book != book)
if (s->inst.book != book)
{
s->book = book;
qof_collection_insert_entity (col, &s->entity);
s->inst.book = book;
qof_collection_insert_entity (col, &s->inst.entity);
}

/* Find the twin account, and re-parent to that. */
Expand Down Expand Up @@ -234,10 +234,10 @@ gnc_book_insert_lot (QofBook *book, GNCLot *lot)
for (snode = lot->splits; snode; snode=snode->next)
{
Split *s = snode->data;
if (s->book != book)
if (s->inst.book != book)
{
s->book = book;
qof_collection_insert_entity (col, &s->entity);
s->inst.book = book;
qof_collection_insert_entity (col, &s->inst.entity);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/engine/Scrub2.c
Expand Up @@ -232,7 +232,7 @@ is_subsplit (Split *split)
g_return_val_if_fail (split->parent, FALSE);

/* If there are no sub-splits, then there's nothing to do. */
kval = kvp_frame_get_slot (split->kvp_data, "lot-split");
kval = kvp_frame_get_slot (split->inst.kvp_data, "lot-split");
if (!kval) return FALSE;

return TRUE;
Expand Down Expand Up @@ -320,27 +320,27 @@ remove_guids (Split *sa, Split *sb)
KvpFrame *ksub;

/* Find and remove the matching guid's */
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sa->kvp_data, "lot-split",
"peer_guid", &sb->entity.guid);
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sa->inst.kvp_data, "lot-split",
"peer_guid", &sb->inst.entity.guid);
if (ksub)
{
gnc_kvp_bag_remove_frame (sa->kvp_data, "lot-split", ksub);
gnc_kvp_bag_remove_frame (sa->inst.kvp_data, "lot-split", ksub);
kvp_frame_delete (ksub);
}

/* Now do it in the other direction */
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sb->kvp_data, "lot-split",
"peer_guid", &sa->entity.guid);
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sb->inst.kvp_data, "lot-split",
"peer_guid", &sa->inst.entity.guid);
if (ksub)
{
gnc_kvp_bag_remove_frame (sb->kvp_data, "lot-split", ksub);
gnc_kvp_bag_remove_frame (sb->inst.kvp_data, "lot-split", ksub);
kvp_frame_delete (ksub);
}

/* Finally, merge b's lot-splits, if any, into a's */
/* This is an important step, if it got busted into many pieces. */
gnc_kvp_bag_merge (sa->kvp_data, "lot-split",
sb->kvp_data, "lot-split");
gnc_kvp_bag_merge (sa->inst.kvp_data, "lot-split",
sb->inst.kvp_data, "lot-split");
}

/* The merge_splits() routine causes the amount & value of sb
Expand Down

0 comments on commit c1ef3fd

Please sign in to comment.