r16038 - gnucash/trunk - Move QofInstance book properties from its public data structure to its
David Hampton
hampton at cvs.gnucash.org
Tue May 1 23:18:47 EDT 2007
Author: hampton
Date: 2007-05-01 23:18:46 -0400 (Tue, 01 May 2007)
New Revision: 16038
Trac: http://svn.gnucash.org/trac/changeset/16038
Modified:
gnucash/trunk/lib/libqof/qof/qofinstance.c
gnucash/trunk/lib/libqof/qof/qofinstance.h
gnucash/trunk/src/backend/postgres/txn.c
gnucash/trunk/src/business/business-core/gncBillTerm.c
gnucash/trunk/src/business/business-core/gncInvoice.c
gnucash/trunk/src/business/business-core/gncTaxTable.c
gnucash/trunk/src/engine/Account.c
gnucash/trunk/src/engine/Period.c
gnucash/trunk/src/engine/Scrub.c
gnucash/trunk/src/engine/Split.c
gnucash/trunk/src/engine/Transaction.c
gnucash/trunk/src/engine/cap-gains.c
gnucash/trunk/src/engine/gnc-pricedb.c
Log:
Move QofInstance book properties from its public data structure to its
private data structure.
Modified: gnucash/trunk/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/lib/libqof/qof/qofinstance.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -65,7 +65,7 @@
QofCollection *collection; /**< Entity collection */
/* The entity_table in which this instance is stored */
-// QofBook * book;
+ QofBook * book;
/* kvp_data is a key-value pair database for storing arbirtary
* information associated with this instance.
@@ -210,7 +210,7 @@
QofInstancePrivate *priv;
priv = GET_PRIVATE(inst);
- inst->book = NULL;
+ priv->book = NULL;
inst->kvp_data = kvp_frame_new();
priv->last_update.tv_sec = 0;
priv->last_update.tv_nsec = -1;
@@ -229,9 +229,9 @@
g_return_if_fail(QOF_IS_INSTANCE(inst));
priv = GET_PRIVATE(inst);
- g_return_if_fail(!inst->book);
+ g_return_if_fail(!priv->book);
- inst->book = book;
+ priv->book = book;
col = qof_book_get_collection (book, type);
g_return_if_fail(col != NULL);
@@ -313,7 +313,7 @@
g_value_set_pointer(value, priv->collection);
break;
case PROP_BOOK:
- g_value_set_object(value, inst->book);
+ g_value_set_object(value, priv->book);
break;
case PROP_KVP_DATA:
g_value_set_pointer(value, inst->kvp_data);
@@ -426,19 +426,43 @@
}
QofBook *
-qof_instance_get_book (const QofInstance *inst)
+qof_instance_get_book (gconstpointer inst)
{
if (!inst) return NULL;
- return inst->book;
+ g_return_val_if_fail(QOF_IS_INSTANCE(inst), NULL);
+ return GET_PRIVATE(inst)->book;
}
void
qof_instance_set_book (gconstpointer inst, QofBook *book)
{
g_return_if_fail(QOF_IS_INSTANCE(inst));
- QOF_INSTANCE(inst)->book = book;
+ GET_PRIVATE(inst)->book = book;
}
+void
+qof_instance_copy_book (gpointer ptr1, gconstpointer ptr2)
+{
+ g_return_if_fail(QOF_IS_INSTANCE(ptr1));
+ g_return_if_fail(QOF_IS_INSTANCE(ptr2));
+
+ GET_PRIVATE(ptr1)->book = GET_PRIVATE(ptr2)->book;
+}
+
+gboolean
+qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2)
+{
+ const QofInstancePrivate *priv1, *priv2;
+
+ g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), FALSE);
+ g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), FALSE);
+
+ priv1 = GET_PRIVATE(ptr1);
+ priv2 = GET_PRIVATE(ptr2);
+
+ return (priv1->book == priv2->book);
+}
+
KvpFrame*
qof_instance_get_slots (const QofInstance *inst)
{
@@ -627,11 +651,11 @@
from_priv = GET_PRIVATE(from);
to_priv = GET_PRIVATE(to);
- fb_priv = GET_PRIVATE(QOF_INSTANCE(from)->book);
- tb_priv = GET_PRIVATE(QOF_INSTANCE(to)->book);
+ fb_priv = GET_PRIVATE(from_priv->book);
+ tb_priv = GET_PRIVATE(to_priv->book);
/* Books must differ for a gemini to be meaningful */
- if (from->book == to->book)
+ if (from_priv->book == to_priv->book)
return;
now = time(0);
@@ -639,11 +663,11 @@
/* Make a note of where the copy came from */
gnc_kvp_bag_add (to->kvp_data, "gemini", now,
"inst_guid", &from->guid,
- "book_guid", &from->book->inst.guid,
+ "book_guid", &from_priv->book->inst.guid,
NULL);
gnc_kvp_bag_add (from->kvp_data, "gemini", now,
"inst_guid", &to->guid,
- "book_guid", &to->book->inst.guid,
+ "book_guid", &to_priv->book->inst.guid,
NULL);
to_priv->dirty = TRUE;
@@ -690,7 +714,7 @@
if (0 >= priv->editlevel)
priv->editlevel = 1;
- be = qof_book_get_backend(inst->book);
+ be = qof_book_get_backend(priv->book);
if (be && qof_backend_begin_exists(be))
qof_backend_run_begin(be, inst);
else
@@ -711,7 +735,7 @@
if (0 < priv->editlevel) return FALSE;
if ((0 == priv->editlevel) && priv->dirty) {
- be = qof_book_get_backend(inst->book);
+ be = qof_book_get_backend(priv->book);
if (be && qof_backend_commit_exists(be)) {
qof_backend_run_commit(be, inst);
}
@@ -737,7 +761,7 @@
dirty = priv->dirty;
/* See if there's a backend. If there is, invoke it. */
- be = qof_book_get_backend(inst->book);
+ be = qof_book_get_backend(priv->book);
if (be && qof_backend_commit_exists(be)) {
QofBackendError errcode;
@@ -764,7 +788,7 @@
if (dirty && qof_get_alt_dirty_mode() &&
!(priv->infant && priv->do_free)) {
qof_collection_mark_dirty(priv->collection);
- qof_book_mark_dirty(inst->book);
+ qof_book_mark_dirty(priv->book);
}
priv->infant = FALSE;
Modified: gnucash/trunk/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance.h 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/lib/libqof/qof/qofinstance.h 2007-05-02 03:18:46 UTC (rev 16038)
@@ -69,9 +69,6 @@
QofIdType e_type; /**< Entity type */
GUID guid; /**< GUID for the entity */
- /* The entity_table in which this instance is stored */
- QofBook * book;
-
/* kvp_data is a key-value pair database for storing arbirtary
* information associated with this instance.
* See src/engine/kvp_doc.txt for a list and description of the
@@ -91,11 +88,17 @@
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
/** Return the book pointer */
-QofBook * qof_instance_get_book (const QofInstance *);
+QofBook *qof_instance_get_book (gconstpointer);
/** Set the book pointer */
void qof_instance_set_book (gconstpointer inst, QofBook *book);
+/** Copy the book from one QofInstances to another. */
+void qof_instance_copy_book (gpointer ptr1, gconstpointer ptr2);
+
+/** See if two QofInstances share the same book. */
+gboolean qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2);
+
/** Return the GUID of this instance */
const GUID * qof_instance_get_guid (const QofInstance *);
Modified: gnucash/trunk/src/backend/postgres/txn.c
===================================================================
--- gnucash/trunk/src/backend/postgres/txn.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/backend/postgres/txn.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -467,7 +467,7 @@
s = pgendSplitLookup (be, &guid);
if (!s)
{
- s = xaccMallocSplit(trans->inst.book);
+ s = xaccMallocSplit(qof_instance_get_book(trans));
xaccSplitSetGUID(s, &guid);
}
Modified: gnucash/trunk/src/business/business-core/gncBillTerm.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncBillTerm.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/business/business-core/gncBillTerm.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -98,14 +98,14 @@
struct _book_info *bi;
if (term->parent || term->invisible) return;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
bi->terms = g_list_sort (bi->terms, (GCompareFunc)gncBillTermCompare);
}
static inline void addObj (GncBillTerm *term)
{
struct _book_info *bi;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
bi->terms = g_list_insert_sorted (bi->terms, term,
(GCompareFunc)gncBillTermCompare);
}
@@ -113,7 +113,7 @@
static inline void remObj (GncBillTerm *term)
{
struct _book_info *bi;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(term), _GNC_MOD_NAME);
bi->terms = g_list_remove (bi->terms, term);
}
@@ -524,7 +524,7 @@
GncBillTerm *t;
if (!term) return NULL;
- t = gncBillTermCreate (term->inst.book);
+ t = gncBillTermCreate (qof_instance_get_book(term));
gncBillTermBeginEdit(t);
Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -858,6 +858,7 @@
const char * memo, gboolean accumulatesplits)
{
Transaction *txn;
+ QofBook *book;
GNCLot *lot = NULL;
GList *iter;
GList *splitinfo = NULL;
@@ -871,6 +872,7 @@
if (!invoice || !acc) return NULL;
gncInvoiceBeginEdit (invoice);
+ book = qof_instance_get_book(invoice);
/* Stabilize the Billing Terms of this invoice */
if (invoice->terms)
@@ -903,7 +905,7 @@
/* Create a new lot for this invoice, if we need to do so */
if (!lot)
- lot = gnc_lot_new (invoice->inst.book);
+ lot = gnc_lot_new (book);
type = gncInvoiceGetType (invoice);
@@ -913,7 +915,7 @@
g_free (lot_title);
/* Create a new transaction */
- txn = xaccMallocTransaction (invoice->inst.book);
+ txn = xaccMallocTransaction (book);
xaccTransBeginEdit (txn);
name = gncOwnerGetName (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice)));
@@ -971,7 +973,7 @@
} else {
Split *split;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (book);
/* set action and memo? */
xaccSplitSetMemo (split, gncEntryGetDescription (entry));
@@ -1002,7 +1004,7 @@
if (ccard_acct && gncEntryGetBillPayment (entry) == GNC_PAYMENT_CARD) {
Split *split;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (book);
/* set action? */
xaccSplitSetMemo (split, gncEntryGetDescription (entry));
xaccSplitSetAction (split, type);
@@ -1036,7 +1038,7 @@
Split *split;
GncAccountValue *acc_val = iter->data;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (book);
/* set action and memo? */
xaccSplitSetMemo (split, memo);
@@ -1055,7 +1057,7 @@
* we should make that now..
*/
if (ccard_acct && !gnc_numeric_zero_p (invoice->to_charge_amount)) {
- Split *split = xaccMallocSplit (invoice->inst.book);
+ Split *split = xaccMallocSplit (book);
/* Set memo. action? */
xaccSplitSetMemo (split, _("Extra to Charge Card"));
@@ -1075,7 +1077,7 @@
/* Now create the Posted split (which is negative -- it's a credit) */
{
- Split *split = xaccMallocSplit (invoice->inst.book);
+ Split *split = xaccMallocSplit (book);
/* Set action/memo */
xaccSplitSetMemo (split, memo);
@@ -1118,8 +1120,8 @@
char *memo2 = _("Automatic Payment Forward");
char *action2 = _("Auto Split");
- t2 = xaccMallocTransaction (invoice->inst.book);
- lot2 = gnc_lot_new (invoice->inst.book);
+ t2 = xaccMallocTransaction (book);
+ lot2 = gnc_lot_new (book);
gncOwnerAttachToLot (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice)),
lot2);
@@ -1136,7 +1138,7 @@
xaccTransSetDatePostedTS (t2, post_date);
/* Balance out this lot */
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (book);
xaccSplitSetMemo (split, memo2);
xaccSplitSetAction (split, action2);
xaccAccountInsertSplit (acc, split);
@@ -1146,7 +1148,7 @@
gnc_lot_add_split (lot, split);
/* And apply the pre-payment to a new lot */
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (book);
xaccSplitSetMemo (split, memo2);
xaccSplitSetAction (split, action2);
xaccAccountInsertSplit (acc, split);
Modified: gnucash/trunk/src/business/business-core/gncTaxTable.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncTaxTable.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/business/business-core/gncTaxTable.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -158,7 +158,7 @@
struct _book_info *bi;
if (table->parent || table->invisible) return;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi->tables = g_list_sort (bi->tables, (GCompareFunc)gncTaxTableCompare);
}
@@ -171,7 +171,7 @@
static inline void addObj (GncTaxTable *table)
{
struct _book_info *bi;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi->tables = g_list_insert_sorted (bi->tables, table,
(GCompareFunc)gncTaxTableCompare);
}
@@ -179,7 +179,7 @@
static inline void remObj (GncTaxTable *table)
{
struct _book_info *bi;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi->tables = g_list_remove (bi->tables, table);
}
@@ -449,7 +449,7 @@
if (!table) return;
gncTaxTableBeginEdit (table);
table->invisible = TRUE;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi->tables = g_list_remove (bi->tables, table);
gncTaxTableCommitEdit (table);
}
@@ -600,7 +600,7 @@
GList *list;
if (!table) return NULL;
- t = gncTaxTableCreate (table->inst.book);
+ t = gncTaxTableCreate (qof_instance_get_book(table));
gncTaxTableSetName (t, table->name);
for (list = table->entries; list; list=list->next) {
GncTaxTableEntry *entry, *e;
Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/Account.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -1106,6 +1106,7 @@
xaccAccountCommitEdit (Account *acc)
{
AccountPrivate *priv;
+ QofBook *book;
g_return_if_fail(acc);
if (!qof_commit_edit(&acc->inst)) return;
@@ -1141,8 +1142,9 @@
g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
*/
- if (!qof_book_shutting_down(acc->inst.book)) {
- col = qof_book_get_collection(acc->inst.book, GNC_ID_TRANS);
+ book = qof_instance_get_book(acc);
+ if (!qof_book_shutting_down(book)) {
+ col = qof_book_get_collection(book, GNC_ID_TRANS);
qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
}
@@ -1816,7 +1818,7 @@
return;
/* check for book mix-up */
- g_return_if_fail (accfrom->inst.book == accto->inst.book);
+ g_return_if_fail (qof_instance_books_equal(accfrom, accto));
ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
xaccAccountBeginEdit(accfrom);
@@ -1895,7 +1897,7 @@
if (qof_instance_get_editlevel(acc) > 0) return;
if (!priv->balance_dirty) return;
if (qof_instance_get_destroying(acc)) return;
- if (qof_book_shutting_down(acc->inst.book)) return;
+ if (qof_book_shutting_down(qof_instance_get_book(acc))) return;
balance = priv->starting_balance;
cleared_balance = priv->starting_cleared_balance;
@@ -2257,6 +2259,7 @@
void
DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
{
+ QofBook *book;
const char *string;
gnc_commodity *commodity;
@@ -2272,7 +2275,8 @@
commodity = DxaccAccountGetCurrency (acc);
if (!commodity)
{
- gnc_commodity_table_insert (gnc_commodity_table_get_table (acc->inst.book), currency);
+ book = qof_instance_get_book(acc);
+ gnc_commodity_table_insert (gnc_commodity_table_get_table (book), currency);
}
}
@@ -2302,7 +2306,7 @@
if (old_parent) {
gnc_account_remove_child(old_parent, child);
- if (old_parent->inst.book != new_parent->inst.book) {
+ if (!qof_instance_books_equal(old_parent, new_parent)) {
/* hack alert -- this implementation is not exactly correct.
* If the entity tables are not identical, then the 'from' book
* may have a different backend than the 'to' book. This means
@@ -2317,7 +2321,8 @@
PWARN ("reparenting accounts across books is not correctly supported\n");
qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL);
- col = qof_book_get_collection (new_parent->inst.book, GNC_ID_ACCOUNT);
+ col = qof_book_get_collection (qof_instance_get_book(new_parent),
+ GNC_ID_ACCOUNT);
qof_collection_insert_entity (col, &child->inst);
qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL);
}
@@ -2847,7 +2852,7 @@
s = kvp_value_get_string (v);
if (!s) return NULL;
- table = gnc_commodity_table_get_table (acc->inst.book);
+ table = gnc_commodity_table_get_table (qof_instance_get_book(acc));
return gnc_commodity_table_lookup_unique (table, s);
}
Modified: gnucash/trunk/src/engine/Period.c
===================================================================
--- gnucash/trunk/src/engine/Period.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/Period.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -72,7 +72,7 @@
if (!trans || !book) return;
/* If this is the same book, its a no-op. */
- if (trans->inst.book == book) return;
+ if (qof_instance_get_book(trans) == book) return;
ENTER ("trans=%p %s", trans, trans->description);
newtrans = xaccDupeTransaction (trans);
@@ -90,7 +90,7 @@
/* Fiddle the transaction into place in the new book */
col = qof_book_get_collection (book, GNC_ID_TRANS);
qof_collection_insert_entity (col, &newtrans->inst);
- newtrans->inst.book = book;
+ qof_instance_set_book(newtrans, book);
col = qof_book_get_collection (book, GNC_ID_SPLIT);
xaccTransBeginEdit (newtrans);
@@ -100,7 +100,7 @@
Split *s = node->data;
/* move the split into the new book ... */
- s->inst.book = book;
+ qof_instance_set_book(s, book);
qof_collection_insert_entity(col, &s->inst);
/* find the twin account, and re-parent to that. */
@@ -130,16 +130,18 @@
gnc_book_insert_trans (QofBook *book, Transaction *trans)
{
QofCollection *col;
+ QofBook *trans_book;
GList *node;
if (!trans || !book) return;
/* If this is the same book, its a no-op. */
- if (trans->inst.book == book) return;
+ trans_book = qof_instance_get_book(trans);
+ if (trans_book == book) return;
/* If the old and new book don't share backends, then clobber-copy;
* i.e. destroy it in one backend, create it in another. */
- if (qof_book_get_backend(book) != qof_book_get_backend(trans->inst.book))
+ if (qof_book_get_backend(book) != qof_book_get_backend(trans_book))
{
gnc_book_insert_trans_clobber (book, trans);
return;
@@ -150,7 +152,7 @@
xaccTransBeginEdit (trans);
col = qof_book_get_collection (book, GNC_ID_TRANS);
- trans->inst.book = book;
+ qof_instance_set_book(trans, book);
qof_collection_insert_entity (col, &trans->inst);
col = qof_book_get_collection (book, GNC_ID_SPLIT);
@@ -160,9 +162,9 @@
Split *s = node->data;
/* Move the splits over (only if they haven't already been moved). */
- if (s->inst.book != book)
+ if (qof_instance_get_book(s) != book)
{
- s->inst.book = book;
+ qof_instance_set_book(s, book);
qof_collection_insert_entity (col, &s->inst);
}
@@ -225,7 +227,7 @@
ENTER ("lot=%p", lot);
col = qof_book_get_collection (book, GNC_ID_LOT);
- lot->inst.book = book;
+ qof_instance_set_book(lot, book);
qof_collection_insert_entity (col, &lot->inst);
/* Move the splits over (only if they haven't already been moved). */
@@ -233,9 +235,9 @@
for (snode = lot->splits; snode; snode=snode->next)
{
Split *s = snode->data;
- if (s->inst.book != book)
+ if (qof_instance_get_book(s) != book)
{
- s->inst.book = book;
+ qof_instance_set_book(s, book);
qof_collection_insert_entity (col, &s->inst);
}
}
@@ -258,14 +260,17 @@
gnc_book_insert_price (QofBook *book, GNCPrice *pr)
{
QofCollection *col;
+ QofBook *pr_book;
+
if (!pr || !book) return;
/* If this is the same book, its a no-op. */
- if (pr->inst.book == book) return;
+ pr_book = qof_instance_get_book(pr);
+ if (pr_book == book) return;
/* If the old and new book don't share backends, then clobber-copy;
* i.e. destroy it in one backend, create it in another. */
- if (qof_book_get_backend(book) != qof_book_get_backend(pr->inst.book))
+ if (qof_book_get_backend(book) != qof_book_get_backend(pr_book))
{
gnc_book_insert_price_clobber (book, pr);
return;
@@ -277,7 +282,7 @@
gnc_price_begin_edit (pr);
col = qof_book_get_collection (book, GNC_ID_PRICE);
- pr->inst.book = book;
+ qof_instance_set_book(pr, book);
qof_collection_insert_entity (col, &pr->inst);
gnc_pricedb_remove_price (pr->db, pr);
Modified: gnucash/trunk/src/engine/Scrub.c
===================================================================
--- gnucash/trunk/src/engine/Scrub.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/Scrub.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -398,7 +398,7 @@
/* Put split into account before setting split value */
if (!balance_split)
{
- balance_split = xaccMallocSplit (trans->inst.book);
+ balance_split = xaccMallocSplit (qof_instance_get_book(trans));
xaccTransBeginEdit (trans);
xaccSplitSetParent(balance_split, trans);
@@ -575,7 +575,7 @@
currency = xaccTransGetCurrency (trans);
if (currency) return;
- currency = xaccTransFindOldCommonCurrency (trans, trans->inst.book);
+ currency = xaccTransFindOldCommonCurrency (trans, qof_instance_get_book(trans));
if (currency)
{
xaccTransBeginEdit (trans);
Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/Split.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -174,7 +174,7 @@
*/
split->inst.e_type = NULL;
split->inst.guid = s->inst.guid;
- split->inst.book = s->inst.book;
+ qof_instance_copy_book(split, s);
split->parent = s->parent;
split->acc = s->acc;
@@ -221,7 +221,7 @@
split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL;
- qof_instance_init_data(&split->inst, GNC_ID_SPLIT, s->inst.book);
+ qof_instance_init_data(&split->inst, GNC_ID_SPLIT, qof_instance_get_book(s));
kvp_frame_delete(split->inst.kvp_data);
split->inst.kvp_data = kvp_frame_copy(s->inst.kvp_data);
@@ -239,7 +239,7 @@
{
printf(" %s Split %p", tag, split);
printf(" GUID: %s\n", guid_to_string(&split->guid));
- printf(" Book: %p\n", split->inst.book);
+ printf(" Book: %p\n", qof_instance_get_book(split));
printf(" Account: %p\n", split->acc);
printf(" Lot: %p\n", split->lot);
printf(" Parent: %p\n", split->parent);
@@ -487,7 +487,7 @@
Transaction *trans;
g_return_if_fail(s && acc);
- g_return_if_fail(acc->inst.book == s->inst.book);
+ g_return_if_fail(qof_instance_books_equal(acc, s));
trans = s->parent;
if (trans)
@@ -636,7 +636,7 @@
split->gains = GAINS_STATUS_A_VDIRTY | GAINS_STATUS_DATE_DIRTY;
} else {
QofCollection *col;
- col = qof_book_get_collection (split->inst.book, GNC_ID_SPLIT);
+ col = qof_book_get_collection (qof_instance_get_book(split), GNC_ID_SPLIT);
split->gains = GAINS_STATUS_GAINS;
other = (Split *) qof_collection_lookup_entity (col,
kvp_value_get_guid (val));
Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/Transaction.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -397,7 +397,7 @@
*/
trans->inst.e_type = NULL;
trans->inst.guid = *guid_null();
- trans->inst.book = t->inst.book;
+ qof_instance_copy_book(trans, t);
trans->inst.kvp_data = kvp_frame_copy (t->inst.kvp_data);
return trans;
@@ -428,7 +428,7 @@
trans->orig = NULL;
trans->idata = 0;
- qof_instance_init_data (&trans->inst, GNC_ID_TRANS, t->inst.book);
+ qof_instance_init_data (&trans->inst, GNC_ID_TRANS, qof_instance_get_book(t));
kvp_frame_delete (trans->inst.kvp_data);
trans->inst.kvp_data = kvp_frame_copy (t->inst.kvp_data);
@@ -841,7 +841,7 @@
if (!trans) return;
if (!qof_begin_edit(&trans->inst)) return;
- if (qof_book_shutting_down(trans->inst.book)) return;
+ if (qof_book_shutting_down(qof_instance_get_book(trans))) return;
xaccOpenLog ();
xaccTransWriteLog (trans, 'B');
@@ -860,7 +860,7 @@
if (!trans) return;
if (!xaccTransGetReadOnly (trans) ||
- qof_book_shutting_down(trans->inst.book)) {
+ qof_book_shutting_down(qof_instance_get_book(trans))) {
xaccTransBeginEdit(trans);
qof_instance_set_destroying(trans, TRUE);
xaccTransCommitEdit(trans);
@@ -891,7 +891,7 @@
do_destroy (Transaction *trans)
{
SplitList *node;
- gboolean shutting_down = qof_book_shutting_down(trans->inst.book);
+ gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(trans));
/* If there are capital-gains transactions associated with this,
* they need to be destroyed too. */
@@ -1156,7 +1156,7 @@
/* Now that the engine copy is back to its original version,
* get the backend to fix it in the database */
- be = qof_book_get_backend (trans->inst.book);
+ be = qof_book_get_backend(qof_instance_get_book(trans));
/** \todo Fix transrollbackedit in QOF so that rollback
is exposed via the API. */
if (be && be->rollback)
@@ -1812,7 +1812,7 @@
g_return_val_if_fail(trans, NULL);
guid = kvp_frame_get_guid(trans->inst.kvp_data, TRANS_REVERSED_BY);
- return xaccTransLookup(guid, trans->inst.book);
+ return xaccTransLookup(guid, qof_instance_get_book(trans));
}
void
Modified: gnucash/trunk/src/engine/cap-gains.c
===================================================================
--- gnucash/trunk/src/engine/cap-gains.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/cap-gains.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -310,7 +310,7 @@
vvv = kvp_frame_get_slot (cwd, cur_name);
gain_acct_guid = kvp_value_get_guid (vvv);
- gain_acct = xaccAccountLookup (gain_acct_guid, acc->inst.book);
+ gain_acct = xaccAccountLookup (gain_acct_guid, qof_instance_get_book(acc));
return gain_acct;
}
@@ -338,7 +338,7 @@
vvv = kvp_frame_get_slot (cwd, cur_name);
gain_acct_guid = kvp_value_get_guid (vvv);
- gain_acct = xaccAccountLookup (gain_acct_guid, acc->inst.book);
+ gain_acct = xaccAccountLookup (gain_acct_guid, qof_instance_get_book(acc));
/* If there is no default place to put gains/losses
* for this account, then create such a place */
@@ -529,7 +529,7 @@
/* Put the remainder of the balance into a new split,
* which is in other respects just a clone of this one. */
- new_split = xaccMallocSplit (acc->inst.book);
+ new_split = xaccMallocSplit (qof_instance_get_book(acc));
/* Copy most of the split attributes */
xaccSplitSetMemo (new_split, xaccSplitGetMemo (split));
@@ -578,7 +578,7 @@
gint64 id;
char buff[200];
- lot = gnc_lot_new (acc->inst.book);
+ lot = gnc_lot_new (qof_instance_get_book(acc));
/* Provide a reasonable title for the new lot */
id = kvp_frame_get_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id");
@@ -945,7 +945,7 @@
if (NULL == lot_split)
{
Account *lot_acc = lot->account;
- QofBook *book = lot_acc->inst.book;
+ QofBook *book = qof_instance_get_book(lot_acc);
new_gain_split = TRUE;
Modified: gnucash/trunk/src/engine/gnc-pricedb.c
===================================================================
--- gnucash/trunk/src/engine/gnc-pricedb.c 2007-05-02 01:57:49 UTC (rev 16037)
+++ gnucash/trunk/src/engine/gnc-pricedb.c 2007-05-02 03:18:46 UTC (rev 16038)
@@ -816,7 +816,7 @@
db, p, qof_instance_get_dirty_flag(p),
qof_instance_get_destroying(p));
- if (db->inst.book != p->inst.book)
+ if (!qof_instance_books_equal(db, p))
{
PERR ("attempted to mix up prices across different books");
LEAVE (" ");
More information about the gnucash-changes
mailing list