QoF
Neil Williams
linux at codehelp.co.uk
Sun May 2 16:03:52 EDT 2004
I'm trying to understand QoF using the sourceforge example:
http://qof.sourceforge.net/my-obj-example.c.html
This is part of a file (I have a header and a genuine makefile to compile) but
I keep getting an empty GList returned at this line:
printf("Debug: %s\n","zero length objects");
int main() {
gnc_engine_get_string_cache();
guid_init();
qof_object_initialize ();
qof_query_init ();
qof_book_register ();
/*gncInvoice*/
GList *n;
GNCBook* testbook = gnc_book_new();
GncInvoice *firstinvoice = gncInvoiceCreate (testbook);
gncInvoiceSetID(firstinvoice, "1001");
gncInvoiceSetActive(firstinvoice, TRUE);
GncInvoice *secondinvoice = gncInvoiceCreate (testbook);
gncInvoiceSetID(secondinvoice, "2002");
gncInvoiceSetActive(secondinvoice, TRUE);
printf("Invoice ID: %s\n", gncInvoiceGetID(firstinvoice));
QofCollection *coll = qof_book_get_collection (testbook, GNC_ID_INVOICE);
GList *all_my_objs = qof_collection_get_data (coll);
if(g_list_length(all_my_objs) == 0) {
printf("Debug: %s\n","zero length objects");
all_my_objs = g_list_prepend(all_my_objs, secondinvoice);
}
for (n=all_my_objs; n; n=n->next) {
GncInvoice *m = n->data;
printf ("id=%s\n", gncInvoiceGetID(m));
}
}
The forced addition of secondinvoice renders the expected id=2002\n output but
I should be getting both 1001 and 2002, shouldn't I?
What am I missing?
Do I need more objects in testbook before the invoices are properly registered
or do the invoices need more data before the qof hashtable lookup can work?
--
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/20040502/171ce38f/attachment.bin
More information about the gnucash-devel
mailing list