r23167 - gnucash/trunk/src/engine - Fix up state-changing business functions
John Ralls
jralls at code.gnucash.org
Fri Sep 13 19:36:36 EDT 2013
Author: jralls
Date: 2013-09-13 19:36:36 -0400 (Fri, 13 Sep 2013)
New Revision: 23167
Trac: http://svn.gnucash.org/trac/changeset/23167
Modified:
gnucash/trunk/src/engine/gncBillTerm.c
gnucash/trunk/src/engine/gncEmployee.c
gnucash/trunk/src/engine/gncEntry.c
gnucash/trunk/src/engine/gncInvoice.c
gnucash/trunk/src/engine/gncJob.c
gnucash/trunk/src/engine/gncOrder.c
gnucash/trunk/src/engine/gncTaxTable.c
Log:
Fix up state-changing business functions
To ensure that they all have a begin/commit and mark the instance
dirty so that the change is immediately written to the DB.
Modified: gnucash/trunk/src/engine/gncBillTerm.c
===================================================================
--- gnucash/trunk/src/engine/gncBillTerm.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncBillTerm.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -404,6 +404,7 @@
{
gncBillTermMakeInvisible (term);
}
+ mark_term (term);
gncBillTermCommitEdit (term);
}
@@ -412,6 +413,7 @@
if (!term) return;
gncBillTermBeginEdit (term);
term->child = child;
+ mark_term (term);
gncBillTermCommitEdit (term);
}
@@ -421,6 +423,7 @@
if (term->parent || term->invisible) return; /* children dont need refcounts */
gncBillTermBeginEdit (term);
term->refcount++;
+ mark_term (term);
gncBillTermCommitEdit (term);
}
@@ -428,16 +431,20 @@
{
if (!term) return;
if (term->parent || term->invisible) return; /* children dont need refcounts */
+ g_return_if_fail (term->refcount >= 1);
gncBillTermBeginEdit (term);
term->refcount--;
- g_return_if_fail (term->refcount >= 0);
+ mark_term (term);
gncBillTermCommitEdit (term);
}
void gncBillTermSetRefcount (GncBillTerm *term, gint64 refcount)
{
if (!term) return;
+ gncBillTermBeginEdit (term);
term->refcount = refcount;
+ mark_term (term);
+ gncBillTermCommitEdit (term);
}
void gncBillTermMakeInvisible (GncBillTerm *term)
@@ -446,6 +453,7 @@
gncBillTermBeginEdit (term);
term->invisible = TRUE;
remObj (term);
+ mark_term (term);
gncBillTermCommitEdit (term);
}
@@ -578,6 +586,7 @@
t->discount = term->discount;
t->cutoff = term->cutoff;
+ mark_term (t);
gncBillTermCommitEdit(t);
return t;
Modified: gnucash/trunk/src/engine/gncEmployee.c
===================================================================
--- gnucash/trunk/src/engine/gncEmployee.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncEmployee.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -550,6 +550,7 @@
}
gncEmployeeBeginEdit(employee);
employee->addr = addr;
+ mark_employee (employee);
gncEmployeeCommitEdit(employee);
}
Modified: gnucash/trunk/src/engine/gncEntry.c
===================================================================
--- gnucash/trunk/src/engine/gncEntry.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncEntry.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -844,6 +844,7 @@
}
dest->values_dirty = TRUE;
+ mark_entry (dest);
gncEntryCommitEdit (dest);
}
@@ -1330,6 +1331,7 @@
/* Determine the commodity denominator */
denom = get_entry_commodity_denom (entry);
+ gncEntryBeginEdit (entry);
/* Compute the invoice values */
gncEntryComputeValue (entry->quantity, entry->i_price,
(entry->i_taxable ? entry->i_tax_table : NULL),
@@ -1362,6 +1364,8 @@
entry->b_tax_value_rounded = gnc_numeric_convert (entry->b_tax_value, denom,
GNC_HOW_RND_ROUND_HALF_UP);
entry->values_dirty = FALSE;
+ mark_entry (entry);
+ gncEntryCommitEdit (entry);
}
/* The "Int" functions below are for internal use only.
Modified: gnucash/trunk/src/engine/gncInvoice.c
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncInvoice.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -380,7 +380,7 @@
// Posted-date and the posted Txn is intentionally not copied; the
// copy isn't "posted" but needs to be posted by the user.
-
+ mark_invoice (invoice);
gncInvoiceCommitEdit(invoice);
return invoice;
@@ -621,27 +621,33 @@
if (old == invoice) return; /* I already own this one */
if (old) gncInvoiceRemoveEntry (old, entry);
+ gncInvoiceBeginEdit (invoice);
gncEntrySetInvoice (entry, invoice);
invoice->entries = g_list_insert_sorted (invoice->entries, entry,
(GCompareFunc)gncEntryCompare);
mark_invoice (invoice);
+ gncInvoiceCommitEdit (invoice);
}
void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry)
{
if (!invoice || !entry) return;
+ gncInvoiceBeginEdit (invoice);
gncEntrySetInvoice (entry, NULL);
invoice->entries = g_list_remove (invoice->entries, entry);
mark_invoice (invoice);
+ gncInvoiceCommitEdit (invoice);
}
void gncInvoiceAddPrice (GncInvoice *invoice, GNCPrice *price)
{
if (!invoice || !price) return;
+ gncInvoiceBeginEdit (invoice);
invoice->prices = g_list_prepend(invoice->prices, price);
mark_invoice (invoice);
+ gncInvoiceCommitEdit (invoice);
}
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry)
@@ -656,19 +662,23 @@
if (old == bill) return; /* I already own this one */
if (old) gncBillRemoveEntry (old, entry);
+ gncInvoiceBeginEdit (bill);
gncEntrySetBill (entry, bill);
bill->entries = g_list_insert_sorted (bill->entries, entry,
(GCompareFunc)gncEntryCompare);
mark_invoice (bill);
+ gncInvoiceCommitEdit (bill);
}
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry)
{
if (!bill || !entry) return;
+ gncInvoiceBeginEdit (bill);
gncEntrySetBill (entry, NULL);
bill->entries = g_list_remove (bill->entries, entry);
mark_invoice (bill);
+ gncInvoiceCommitEdit (bill);
}
void gncInvoiceSortEntries (GncInvoice *invoice)
@@ -676,7 +686,9 @@
if (!invoice) return;
invoice->entries = g_list_sort(invoice->entries,
(GCompareFunc)gncEntryCompare);
+ gncInvoiceBeginEdit (invoice);
mark_invoice(invoice);
+ gncInvoiceCommitEdit (invoice);
}
/* ================================================================== */
@@ -1488,6 +1500,10 @@
gncAccountValueDestroy (splitinfo);
gnc_lot_commit_edit (lot);
+ /* Not strictly necessary, since it was done by the Set calls
+ * above, but good insurance. */
+ DEBUG("Committing Invoice %s", invoice->id);
+ mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
/* If requested, attempt to automatically apply open payments
Modified: gnucash/trunk/src/engine/gncJob.c
===================================================================
--- gnucash/trunk/src/engine/gncJob.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncJob.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -338,10 +338,11 @@
{
return;
}
- qof_begin_edit(&job->inst);
+
+ gncJobBeginEdit (job);
qofOwnerSetEntity(&job->owner, ent);
mark_job (job);
- qof_commit_edit(&job->inst);
+ gncJobCommitEdit (job);
}
void gncJobBeginEdit (GncJob *job)
Modified: gnucash/trunk/src/engine/gncOrder.c
===================================================================
--- gnucash/trunk/src/engine/gncOrder.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncOrder.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -399,21 +399,25 @@
if (old == order) return; /* I already own it */
if (old) gncOrderRemoveEntry (old, entry);
+ gncOrderBeginEdit (order);
order->entries = g_list_insert_sorted (order->entries, entry,
(GCompareFunc)gncEntryCompare);
/* This will send out an event -- make sure we're attached */
gncEntrySetOrder (entry, order);
mark_order (order);
+ gncOrderCommitEdit (order);
}
void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry)
{
if (!order || !entry) return;
+ gncOrderBeginEdit (order);
gncEntrySetOrder (entry, NULL);
order->entries = g_list_remove (order->entries, entry);
mark_order (order);
+ gncOrderCommitEdit (order);
}
/* Get Functions */
Modified: gnucash/trunk/src/engine/gncTaxTable.c
===================================================================
--- gnucash/trunk/src/engine/gncTaxTable.c 2013-09-13 23:36:22 UTC (rev 23166)
+++ gnucash/trunk/src/engine/gncTaxTable.c 2013-09-13 23:36:36 UTC (rev 23167)
@@ -499,6 +499,7 @@
gncTaxTableAddChild(parent, table);
table->refcount = 0;
gncTaxTableMakeInvisible (table);
+ mark_table (table);
gncTaxTableCommitEdit (table);
}
@@ -507,6 +508,7 @@
if (!table) return;
gncTaxTableBeginEdit (table);
table->child = child;
+ mark_table (table);
gncTaxTableCommitEdit (table);
}
@@ -516,6 +518,7 @@
if (table->parent || table->invisible) return; /* children dont need refcounts */
gncTaxTableBeginEdit (table);
table->refcount++;
+ mark_table (table);
gncTaxTableCommitEdit (table);
}
@@ -523,16 +526,21 @@
{
if (!table) return;
if (table->parent || table->invisible) return; /* children dont need refcounts */
+ g_return_if_fail (table->refcount > 0);
gncTaxTableBeginEdit (table);
table->refcount--;
- g_return_if_fail (table->refcount >= 0);
+ mark_table (table);
gncTaxTableCommitEdit (table);
}
void gncTaxTableSetRefcount (GncTaxTable *table, gint64 refcount)
{
if (!table) return;
+ g_return_if_fail (refcount >= 0);
+ gncTaxTableBeginEdit (table);
table->refcount = refcount;
+ mark_table (table);
+ gncTaxTableCommitEdit (table);
}
void gncTaxTableMakeInvisible (GncTaxTable *table)
More information about the gnucash-changes
mailing list