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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13957 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-05-08 04:47:04 +00:00
parent 6b925724e7
commit de0c1edcb5
3 changed files with 12 additions and 4 deletions

View File

@ -69,6 +69,9 @@ struct QofInstance_s
* 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 */

View File

@ -61,6 +61,7 @@ qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
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 @@ void
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;

View File

@ -303,16 +303,19 @@ qof_commit_edit_part2(QofInstance *inst,
/* 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;