mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fix core dump
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9093 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
21d44aaaea
commit
d1341ae7ce
@ -152,10 +152,13 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
|
|||||||
Account *twin;
|
Account *twin;
|
||||||
Split *s = node->data;
|
Split *s = node->data;
|
||||||
|
|
||||||
/* Move the split into the new book ... */
|
/* Move the splits over (only if they haven't already been moved). */
|
||||||
qof_entity_remove (s->book->entity_table, &s->guid);
|
if (s->book != book)
|
||||||
s->book = book;
|
{
|
||||||
qof_entity_store(book->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
qof_entity_remove (s->book->entity_table, &s->guid);
|
||||||
|
s->book = book;
|
||||||
|
qof_entity_store(book->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
||||||
|
}
|
||||||
|
|
||||||
/* Find the twin account, and re-parent to that. */
|
/* Find the twin account, and re-parent to that. */
|
||||||
twin = xaccAccountLookupTwin (s->acc, book);
|
twin = xaccAccountLookupTwin (s->acc, book);
|
||||||
@ -165,9 +168,13 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xaccAccountInsertSplit (twin, s);
|
/* Move the split too, if it hasn't been moved already */
|
||||||
twin->balance_dirty = TRUE;
|
if (s->acc != twin)
|
||||||
twin->sort_dirty = TRUE;
|
{
|
||||||
|
xaccAccountInsertSplit (twin, s);
|
||||||
|
twin->balance_dirty = TRUE;
|
||||||
|
twin->sort_dirty = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +202,7 @@ gnc_book_insert_lot_clobber (QofBook *book, GNCLot *lot)
|
|||||||
void
|
void
|
||||||
gnc_book_insert_lot (QofBook *book, GNCLot *lot)
|
gnc_book_insert_lot (QofBook *book, GNCLot *lot)
|
||||||
{
|
{
|
||||||
|
SplitList *snode;
|
||||||
Account *twin;
|
Account *twin;
|
||||||
if (!lot || !book) return;
|
if (!lot || !book) return;
|
||||||
|
|
||||||
@ -211,6 +219,18 @@ gnc_book_insert_lot (QofBook *book, GNCLot *lot)
|
|||||||
lot->book = book;
|
lot->book = book;
|
||||||
qof_entity_store(book->entity_table, lot, &lot->guid, GNC_ID_LOT);
|
qof_entity_store(book->entity_table, lot, &lot->guid, GNC_ID_LOT);
|
||||||
|
|
||||||
|
/* Move the splits over (only if they haven't already been moved). */
|
||||||
|
for (snode = lot->splits; snode; snode=snode->next)
|
||||||
|
{
|
||||||
|
Split *s = snode->data;
|
||||||
|
if (s->book != book)
|
||||||
|
{
|
||||||
|
qof_entity_remove (s->book->entity_table, &s->guid);
|
||||||
|
s->book = book;
|
||||||
|
qof_entity_store(book->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
twin = xaccAccountLookupTwin (lot->account, book);
|
twin = xaccAccountLookupTwin (lot->account, book);
|
||||||
if (!twin)
|
if (!twin)
|
||||||
{
|
{
|
||||||
@ -461,15 +481,15 @@ gnc_book_partition_txn (QofBook *dest_book, QofBook *src_book, QofQuery *query)
|
|||||||
lot_list = create_lot_list_from_trans_list (trans_list);
|
lot_list = create_lot_list_from_trans_list (trans_list);
|
||||||
lot_list = lot_list_preen_open_lots (lot_list);
|
lot_list = lot_list_preen_open_lots (lot_list);
|
||||||
|
|
||||||
/* Move closed lots over to destination. Do this before
|
/* Move closed lots over to destination. Do this before moving
|
||||||
* moving transactions, which should avoid damage to lots. */
|
* the txn's, so that the lots don't get trashed. */
|
||||||
for (lnode = lot_list; lnode; lnode = lnode->next)
|
for (lnode = lot_list; lnode; lnode = lnode->next)
|
||||||
{
|
{
|
||||||
GNCLot *lot = lnode->data;
|
GNCLot *lot = lnode->data;
|
||||||
gnc_book_insert_lot (dest_book, lot);
|
gnc_book_insert_lot (dest_book, lot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move the transactions over */
|
/* Move the transactions over to the destination book. */
|
||||||
for (tnode = trans_list; tnode; tnode=tnode->next)
|
for (tnode = trans_list; tnode; tnode=tnode->next)
|
||||||
{
|
{
|
||||||
Transaction *trans = tnode->data;
|
Transaction *trans = tnode->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user