Dirty entity identification.

David Hampton hampton-gnucash at rainbolthampton.net
Thu Jul 21 20:01:19 EDT 2005


On Fri, 2005-07-22 at 00:14 +0100, Neil Williams wrote:
> On Thursday 21 July 2005 11:55 pm, David Hampton wrote:
> > Neil mentioned he will be modifying the code to use the new function
> > qof_instance_set_dirty() to set dirty flags on collections.  If this
> > function also sets the dirty flag on the book containing the collection
> > then I have almost every thing I need.
> 
> It will. Every call to qof_book_not_saved automatically calls 
> qof_object_is_dirty which checks each collection in the book for the single 
> boolean value in each collection and returns TRUE if ANY collection is dirty. 

You clearly haven't understood my statements.  I don't want to have to
run the list of collections each time I ask if the book is dirty.
That's too much work.  I want to short circuit that entire process by
checking *one* *flag* in the book.  Not the collections.  The book.  I
would like the code that marks the collection as dirty to also mark the
book as dirty.  None of the code I'm working on cares what has changed,
only that something has.

> The collection will (with the new code) be marked as dirty as soon as any 
> entity in that collection is marked as dirty.
> 
> http://code.neil.williamsleesmill.me.uk/gnome2/group__Book.html#ga15
> 
> It's fast because it's only checking a single boolean flag in each case and 
> there are only as many primary collections as there are registered object 
> definitions.

Yes, thanks.  I've seen that code.  (Insert wry face here.)  Nowhere
have you stated that setting the dirty flag on a collection will also
set book->inst.dirty.  In fact, you've gone through some serious
contortions to avoid saying it.

O.K.  Lets try another approach.  The following is what I want.  Tell me
why you can't implement it.

gboolean
qof_book_is_dirty (QofBook *book)
{
	return book->inst.dirty;
}

guint
qof_book_get_dirty_time (QofBook *book)
{
	return book->dirty_time;
}

void
qof_book_set_dirty (QofBook *book)
{
	book->inst.dirty = TRUE;
	if (book->dirty_time == 0)
		book->dirty_time = time();
}

void
qof_book_set_clean (QofBook *book)
{
	book->inst.dirty = FALSE;
	book->dirty_time = 0;
}

qof_instance_set_dirty (...)
{
	...whatever...
	qof_book_set_dirty(book);
}

It totally baffles me why this has taken more than three email messages.
Do you not have a back pointer from the collection to the book?  That
seems like a *HUGE* oversight if that's the problem.

David




More information about the gnucash-devel mailing list