mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-23 01:16:43 -06:00
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:
parent
6b925724e7
commit
de0c1edcb5
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user