[Gnucash-changes] r13390 - gnucash/trunk/lib/libqof/qof - Implement QOF_COMMIT_EDIT_PART2 as a function instead of a macro.

Chris Shoemaker c.shoemaker at cox.net
Sun Feb 26 12:58:22 EST 2006


On Sun, Feb 26, 2006 at 11:57:19AM -0500, Derek Atkins wrote:
> This patch could break a lot of code in lots of places because there
> is code that expects that QOF_COMMIT_EDIT_PART2() could return
> (exiting the /caller/ of the macro), but the new macro wont return
> out of the caller anymore.

Yes, this change would certainly break certain uses of this macro.
However, of all the uses, only one falls in to that case.  I'll fix
that one case to use the function directly.

> 
> A simple fix would be to change the new macro to auto-return:
> 
>   #define QOF_COMMIT_EDIT_PART2(inst, on_error, on_done, on_free)         \
>     if (qof_commit_edit_part2((inst), (on_error), (on_done), (on_free))) { \
>         return; \
>     }
> 
> However even THAT doesn't quite give you the same behavior as
> the old macro.

True.  My intention is to change the behavior.  Specifically, to
change it in a way that is compatible with all the existing uses and
that allows the on_error hook to be used for rollback.  As it was, the
'on_done' was called unconditionally anytime 'on_free' was called,
which is just dumb, because if the user wanted that behavior they
would just call 'on_done' from within 'on_free'.

BTW, eliminating a macro that affects control flow wasn't my
motivation, but it is a fringe benefit.  It's *horrible* practice and
we fortunately only depend(ed) on it in one place.

-chris


More information about the gnucash-devel mailing list