Fix logic for "dirty" setting; only set dirty when data actually

changes.  Only set "global" dirty flag at 'commitedit'


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6990 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2002-06-21 19:00:34 +00:00
parent 99f2cd2ab2
commit 068749c658
12 changed files with 52 additions and 9 deletions

View File

@ -385,6 +385,7 @@ entry_order_handler (xmlNodePtr node, gpointer entry_pdata)
gncOrderSetGUID (order, guid);
}
gncOrderAddEntry (order, pdata->entry);
gncOrderCommitEdit (order);
g_free(guid);
return TRUE;
@ -405,6 +406,7 @@ entry_invoice_handler (xmlNodePtr node, gpointer entry_pdata)
gncInvoiceSetGUID (invoice, guid);
}
gncInvoiceAddEntry (invoice, pdata->entry);
gncInvoiceCommitEdit (invoice);
g_free(guid);
return TRUE;

View File

@ -214,6 +214,12 @@ void gncBillTermChanged (GncBillTerm *term)
void gncBillTermCommitEdit (GncBillTerm *term)
{
if (!term) return;
/* XXX Commit to DB */
if (term->dirty)
gncBusinessSetDirtyFlag (term->book, _GNC_MOD_NAME, TRUE);
term->dirty = FALSE;
}

View File

@ -91,7 +91,6 @@ void gncBusinessAddObject (GNCBook *book, GNCIdType mod_name,
xaccStoreEntity (gnc_book_get_entity_table (book), obj, guid, mod_name);
bi = gnc_book_get_data (book, mod_name);
g_hash_table_insert (bi->ht, (gpointer)guid, obj);
bi->is_dirty = TRUE;
}
void gncBusinessRemoveObject (GNCBook *book, GNCIdType mod_name,
@ -102,5 +101,4 @@ void gncBusinessRemoveObject (GNCBook *book, GNCIdType mod_name,
xaccRemoveEntity (gnc_book_get_entity_table (book), guid);
bi = gnc_book_get_data (book, mod_name);
g_hash_table_remove (bi->ht, guid);
bi->is_dirty = TRUE;
}

View File

@ -195,6 +195,7 @@ void gncCustomerSetCredit (GncCustomer *cust, gnc_numeric credit)
void gncCustomerSetCommodity (GncCustomer *cust, gnc_commodity *com)
{
if (!cust || !com) return;
if (cust->commodity && gnc_commodity_equal (cust->commodity, com)) return;
cust->commodity = com;
mark_customer (cust);
}
@ -234,7 +235,7 @@ void gncCustomerCommitEdit (GncCustomer *cust)
if (!cust) return;
/* XXX COMMIT TO DATABASE */
if (cust->dirty)
if (gncCustomerIsDirty (cust))
gncBusinessSetDirtyFlag (cust->book, _GNC_MOD_NAME, TRUE);
cust->dirty = FALSE;
gncAddressClearDirty (cust->addr);

View File

@ -171,6 +171,9 @@ void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
void gncEmployeeSetCommodity (GncEmployee *employee, gnc_commodity *com)
{
if (!employee || !com) return;
if (employee->commodity &&
gnc_commodity_equal (employee->commodity, com))
return;
employee->commodity = com;
mark_employee (employee);
}
@ -269,7 +272,7 @@ void gncEmployeeCommitEdit (GncEmployee *employee)
if (!employee) return;
/* XXX COMMIT TO DATABASE */
if (employee->dirty)
if (gncEmployeeIsDirty (employee))
gncBusinessSetDirtyFlag (employee->book, _GNC_MOD_NAME, TRUE);
employee->dirty = FALSE;
gncAddressClearDirty (employee->addr);

View File

@ -150,6 +150,7 @@ void gncEntrySetGUID (GncEntry *entry, const GUID *guid)
void gncEntrySetDate (GncEntry *entry, Timespec date)
{
if (!entry) return;
if (timespec_equal (&entry->date, &date)) return;
entry->date = date;
mark_entry (entry);
}
@ -157,6 +158,7 @@ void gncEntrySetDate (GncEntry *entry, Timespec date)
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
{
if (!entry) return;
if (timespec_equal (&entry->date_entered, &date)) return;
entry->date_entered = date;
mark_entry (entry);
}
@ -185,6 +187,7 @@ void gncEntrySetNotes (GncEntry *entry, const char *notes)
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity)
{
if (!entry) return;
if (gnc_numeric_eq (entry->quantity, quantity)) return;
entry->quantity = quantity;
entry->values_dirty = TRUE;
mark_entry (entry);
@ -193,6 +196,7 @@ void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity)
void gncEntrySetPrice (GncEntry *entry, gnc_numeric price)
{
if (!entry) return;
if (gnc_numeric_eq (entry->price, price)) return;
entry->price = price;
entry->values_dirty = TRUE;
mark_entry (entry);
@ -201,6 +205,7 @@ void gncEntrySetPrice (GncEntry *entry, gnc_numeric price)
void gncEntrySetDiscount (GncEntry *entry, gnc_numeric discount)
{
if (!entry) return;
if (gnc_numeric_eq (entry->discount, discount)) return;
entry->discount = discount;
entry->values_dirty = TRUE;
mark_entry (entry);
@ -209,6 +214,7 @@ void gncEntrySetDiscount (GncEntry *entry, gnc_numeric discount)
void gncEntrySetAccount (GncEntry *entry, Account *acc)
{
if (!entry) return;
if (entry->account == acc) return;
entry->account = acc;
mark_entry (entry);
}
@ -217,6 +223,7 @@ void gncEntrySetAccount (GncEntry *entry, Account *acc)
void gncEntrySetOrder (GncEntry *entry, GncOrder *order)
{
if (!entry) return;
if (entry->order == order) return;
entry->order = order;
mark_entry (entry);
@ -229,6 +236,7 @@ void gncEntrySetOrder (GncEntry *entry, GncOrder *order)
void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice)
{
if (!entry) return;
if (entry->invoice == invoice) return;
entry->invoice = invoice;
mark_entry (entry);
}
@ -236,6 +244,7 @@ void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice)
void gncEntrySetTaxable (GncEntry *entry, gboolean taxable)
{
if (!entry) return;
if (entry->taxable == taxable) return;
entry->taxable = taxable;
entry->values_dirty = TRUE;
mark_entry (entry);
@ -244,6 +253,7 @@ void gncEntrySetTaxable (GncEntry *entry, gboolean taxable)
void gncEntrySetTaxIncluded (GncEntry *entry, gboolean taxincluded)
{
if (!entry) return;
if (entry->taxincluded == taxincluded) return;
entry->taxincluded = taxincluded;
entry->values_dirty = TRUE;
mark_entry (entry);
@ -265,6 +275,7 @@ void gncEntrySetTaxTable (GncEntry *entry, GncTaxTable *table)
void gncEntrySetDiscountType (GncEntry *entry, GncAmountType type)
{
if (!entry) return;
if (entry->disc_type == type) return;
entry->disc_type = type;
entry->values_dirty = TRUE;
@ -274,6 +285,7 @@ void gncEntrySetDiscountType (GncEntry *entry, GncAmountType type)
void gncEntrySetDiscountHow (GncEntry *entry, GncDiscountHow how)
{
if (!entry) return;
if (entry->disc_how == how) return;
entry->disc_how = how;
entry->values_dirty = TRUE;

View File

@ -72,8 +72,8 @@ struct _gncInvoice {
static void addObj (GncInvoice *invoice);
static void remObj (GncInvoice *invoice);
G_INLINE_FUNC void mark_invoice (GncInvoice *invoice);
G_INLINE_FUNC void
static void mark_invoice (GncInvoice *invoice);
static void
mark_invoice (GncInvoice *invoice)
{
invoice->dirty = TRUE;
@ -147,6 +147,7 @@ void gncInvoiceSetID (GncInvoice *invoice, const char *id)
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
{
if (!invoice || !owner) return;
if (gncOwnerEqual (&invoice->owner, owner)) return;
gncOwnerCopy (owner, &invoice->owner);
mark_invoice (invoice);
}
@ -154,6 +155,7 @@ void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
if (timespec_equal (&invoice->date_opened, &date)) return;
invoice->date_opened = date;
mark_invoice (invoice);
}
@ -161,6 +163,7 @@ void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date)
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
if (timespec_equal (&invoice->date_posted, &date)) return;
invoice->date_posted = date;
mark_invoice (invoice);
}
@ -189,6 +192,7 @@ void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes)
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active)
{
if (!invoice) return;
if (invoice->active == active) return;
invoice->active = active;
mark_invoice (invoice);
}
@ -196,6 +200,9 @@ void gncInvoiceSetActive (GncInvoice *invoice, gboolean active)
void gncInvoiceSetCommonCommodity (GncInvoice *invoice, gnc_commodity *com)
{
if (!invoice || !com) return;
if (invoice->common_commodity &&
gnc_commodity_equal (invoice->common_commodity, com))
return;
invoice->common_commodity = com;
mark_invoice (invoice);
}
@ -209,6 +216,7 @@ void gncInvoiceSetDirty (GncInvoice *invoice, gboolean dirty)
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn)
{
if (!invoice) return;
g_return_if_fail (invoice->posted_txn == NULL);
invoice->posted_txn = txn;
mark_invoice (invoice);
@ -217,6 +225,7 @@ void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn)
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
{
if (!invoice) return;
g_return_if_fail (invoice->posted_acc == NULL);
invoice->posted_acc = acc;
mark_invoice (invoice);

View File

@ -131,6 +131,7 @@ void gncOrderSetID (GncOrder *order, const char *id)
void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
{
if (!order || !owner) return;
if (gncOwnerEqual (&order->owner, owner)) return;
gncOwnerCopy (owner, &order->owner);
mark_order (order);
@ -139,6 +140,7 @@ void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
void gncOrderSetDateOpened (GncOrder *order, Timespec date)
{
if (!order) return;
if (timespec_equal (&order->opened, &date)) return;
order->opened = date;
mark_order (order);
}
@ -146,6 +148,7 @@ void gncOrderSetDateOpened (GncOrder *order, Timespec date)
void gncOrderSetDateClosed (GncOrder *order, Timespec date)
{
if (!order) return;
if (timespec_equal (&order->closed, &date)) return;
order->closed = date;
mark_order (order);
}
@ -167,6 +170,7 @@ void gncOrderSetReference (GncOrder *order, const char *reference)
void gncOrderSetActive (GncOrder *order, gboolean active)
{
if (!order) return;
if (order->active == active) return;
order->active = active;
mark_order (order);
}

View File

@ -250,6 +250,11 @@ void gncTaxTableChanged (GncTaxTable *table)
void gncTaxTableCommitEdit (GncTaxTable *table)
{
if (!table) return;
if (table->dirty)
gncBusinessSetDirtyFlag (table->book, _GNC_MOD_NAME, TRUE);
table->dirty = FALSE;
}

View File

@ -162,6 +162,9 @@ void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl)
void gncVendorSetCommodity (GncVendor *vendor, gnc_commodity *com)
{
if (!vendor || !com) return;
if (vendor->commodity &&
gnc_commodity_equal (vendor->commodity, com))
return;
vendor->commodity = com;
mark_vendor (vendor);
}
@ -272,7 +275,7 @@ void gncVendorCommitEdit (GncVendor *vendor)
if (!vendor) return;
/* XXX COMMIT TO DATABASE */
if (vendor->dirty)
if (gncVendorIsDirty (vendor))
gncBusinessSetDirtyFlag (vendor->book, _GNC_MOD_NAME, TRUE);
vendor->dirty = FALSE;
gncAddressClearDirty (vendor->addr);

View File

@ -612,7 +612,7 @@ billterms_delete_term_cb (GtkButton *button, BillTermsWindow *btw)
/* Ok, let's remove it */
gnc_suspend_gui_refresh ();
gncBillTermDestroy (btw->current_term);
gncBillTermCommitEdit (btw->current_term);
// gncBillTermCommitEdit (btw->current_term);
btw->current_term = NULL;
gnc_resume_gui_refresh ();
}

View File

@ -508,7 +508,7 @@ tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw)
/* Ok, let's remove it */
gnc_suspend_gui_refresh ();
gncTaxTableDestroy (ttw->current_table);
gncTaxTableCommitEdit (ttw->current_table);
// gncTaxTableCommitEdit (ttw->current_table);
ttw->current_table = NULL;
gnc_resume_gui_refresh ();
}