[Gnucash-changes] r13483 - gnucash/trunk - Rework the events
generated by the account/group files and consumed by
David Hampton
hampton-gnucash at rainbolthampton.net
Mon Mar 6 14:33:13 EST 2006
On Mon, 2006-03-06 at 09:09 -0500, Derek Atkins wrote:
> David,
>
> David Hampton <hampton at cvs.gnucash.org> writes:
>
> > + ed.node = acc;
> > + ed.idx = 0;
> > + qof_event_gen(&acc->inst.entity, QOF_EVENT_MODIFY, &ed);
> > +
> > if (qof_commit_edit_part2(&acc->inst, on_err, noop, acc_free))
> > gnc_engine_gen_event (&acc->inst.entity, GNC_EVENT_MODIFY);
> > }
>
> Two problems here:
>
> 1) You shouldn't need this particular construct for the MODIFY event.
> You can lookup the modified Account based on the QofEntity in the
> event callback, so you shouldn't need to pass the actual Account*
> in the event.
OK, I can see how that should work.
> 2) You've now changed the MODIFY API, and I'm not convinced you've
> changed it globally. That could be dangerous, in particular if the
> event gets emitted from somewhere that didn't know about the
> change.
No, I've added a new modify api using the qof_event_gen function. The
old api using the gnc_engine_gen_event call is still there and is
unchanged. Since the account tree model must use the qof_event system
for the REMOVE notification because of extra data required, it makes
sense to use that API for all the events that account tree model
watches.
The qof_event_gen call should probably be moved inside of the 'if'
statement, but I was getting persistent crashes when it was in that
location. When xaccAccountCommitEdit is called at the end of account
destruction, the commit_edit_part2 call frees the allocated data
structure and then the old callback functions is invoked. I am unclear
why the exiting event generation hook ever worked in this position since
it can be called on a freed data structure. I didn't have time to
analyze the problem further, thus the current location of the call to
qof_event_gen.
David
More information about the gnucash-devel
mailing list