[Gnucash-changes] r13957 - gnucash/trunk/lib/libqof/qof - Add a
flag, 'infant', to QofInstance to note that the instance has been
Chris Shoemaker
chris at cvs.gnucash.org
Mon May 8 00:47:05 EDT 2006
Author: chris
Date: 2006-05-08 00:47:04 -0400 (Mon, 08 May 2006)
New Revision: 13957
Trac: http://svn.gnucash.org/trac/changeset/13957
Modified:
gnucash/trunk/lib/libqof/qof/qofinstance-p.h
gnucash/trunk/lib/libqof/qof/qofinstance.c
gnucash/trunk/lib/libqof/qof/qofutil.c
Log:
Add a flag, 'infant', to QofInstance to note that the instance has been
committed at least once in its lifecycle. Then, we can mark the collection
dirty whenever an object is committed, except for the special case of an
QofInstance that has never been committed before and is now being deleted.
Modified: gnucash/trunk/lib/libqof/qof/qofinstance-p.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance-p.h 2006-05-08 03:04:49 UTC (rev 13956)
+++ gnucash/trunk/lib/libqof/qof/qofinstance-p.h 2006-05-08 04:47:04 UTC (rev 13957)
@@ -69,6 +69,9 @@
* but has not yet been written out to storage (file/database)
*/
gboolean dirty;
+
+ /* True iff this instance has never been committed. */
+ gboolean infant;
};
/* reset the dirty flag */
Modified: gnucash/trunk/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofinstance.c 2006-05-08 03:04:49 UTC (rev 13956)
+++ gnucash/trunk/lib/libqof/qof/qofinstance.c 2006-05-08 04:47:04 UTC (rev 13957)
@@ -61,6 +61,7 @@
inst->editlevel = 0;
inst->do_free = FALSE;
inst->dirty = FALSE;
+ inst->infant = TRUE;
col = qof_book_get_collection (book, type);
qof_entity_init (&inst->entity, type, col);
@@ -70,6 +71,7 @@
qof_instance_release (QofInstance *inst)
{
kvp_frame_delete (inst->kvp_data);
+ inst->kvp_data = NULL;
inst->editlevel = 0;
inst->do_free = FALSE;
inst->dirty = FALSE;
Modified: gnucash/trunk/lib/libqof/qof/qofutil.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofutil.c 2006-05-08 03:04:49 UTC (rev 13956)
+++ gnucash/trunk/lib/libqof/qof/qofutil.c 2006-05-08 04:47:04 UTC (rev 13957)
@@ -303,16 +303,19 @@
/* XXX the backend commit code should clear dirty!! */
inst->dirty = FALSE;
}
+ if (dirty && qof_get_alt_dirty_mode() &&
+ !(inst->infant && inst->do_free)) {
+ qof_collection_mark_dirty(inst->entity.collection);
+ qof_book_mark_dirty(inst->book);
+ }
+ inst->infant = FALSE;
+
if (inst->do_free) {
if (on_free)
on_free(inst);
return TRUE;
}
- if (dirty && qof_get_alt_dirty_mode()) {
- qof_collection_mark_dirty(inst->entity.collection);
- qof_book_mark_dirty(inst->book);
- }
if (on_done)
on_done(inst);
return TRUE;
More information about the gnucash-changes
mailing list