QOF iteration and callbacks
Neil Williams
linux at codehelp.co.uk
Thu Jun 17 09:26:34 EDT 2004
On Thursday 17 June 2004 4:22, Derek Atkins wrote:
> Neil Williams <linux at codehelp.co.uk> writes:
> qof_object_foreach(QOF_TYPE_XXX, book, my_foreach_cb, my_cb_arg);
> Well, DUH, gnc_book_merge_foreach doesn't match the QofEntityForeachCB
> type!
That's what I can't get straight. I haven't used a lot of callback routines
before (hazard of being self-taught) and I can't work out how to get the type
correct.
> Of course this is going to segv, you're passing completely
> bogus data into your function.
I'd be grateful for an example here. I need to understand the callback and how
to determine the type required (I think I have that, but need a check) as
well as how to match that type (my real problem).
From this snippet:
qof_object_foreach(GNC_ID_INVOICE, testbook, gnc_bm_foreach, ud);
The doxygen pages for qof_object_foreach give the types for the last two
parameters as types: QofEntityForeachCB and gpointer.
what would an empty declaration of gnc_bm_foreach need to look like in order
to have a compatible pointer and provide access to the object?
void gnc_bm_foreach (QofEntity obj, gpointer ud1); doesn't work. Why?
(yes, I know calling it obj is misleading, it's an artefact of previous
attempts and is temporary.)
I'm presuming this is a red herring:
void (*gnc_bm_fp) = gnc_bm_foreach;
following a simple function pointer declaration prototype - (nothing to do
with QOF or Gnucash necessarily) although it compiles, I get the same error
as when I was using explicit casting - my brain is getting addled, is that
example a declaration or just another cast?
> > I get:
> > ** CRITICAL **: Error: qof_object_foreach(): No object of type gncInvoice
> > and no debug "foreach running" lines.
>
> See above about the function type being incorrect. Don't cast it. The
> cast it biting you in the ass.
:-)
> You're thinking about it too hard. You're using the right apis but you're
> not using them correctly. Write your callback function properly.
Help! I'm sorry to have to ask about this but I'm stumped.
--
Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20040617/152e1d3e/attachment.bin
More information about the gnucash-devel
mailing list