Multiple QofBook support working

Neil Williams linux at
Wed Sep 15 13:33:39 EDT 2004

On Sunday 05 September 2004 8:19 pm, Derek Atkins wrote:
> Excellent!!!  Nice work.

Thank you!

> I think that a patch that merges this into the gnucash sources would be
> excellent.  Another test-case that would be nice is some way to merge the
> Hierarchy Druid into an existing set of accounts.  E.g., add a menu item:
>    File -> Add New Account Hierarchy

I've been working on that (which is why I haven't replied until now) but I 
have a few problems with druid-hierarchy.c and io-example-account.c - I can't 
read the example files via a second session - even though I can read other 
files from second sessions.

I want to create a QofBook in memory that contains the new Account Hierarchy 
then merge that into the current book. Basically, run the druid with a new 
book, pass that book and the target book to qof_book_mergeInit. 

I've created a copy of druid-hierarchy.c (druid-merge.c) which uses the 
hierarchy code and then adds the merge capability. I've changed the 
gnc_get_current_book() calls to a new book that is created when the druid 
starts up: mergeBook = qof_book_new(); (defined as a static QofBook *).

 previous_session = qof_session_get_current_session();
 targetBook = qof_session_get_book(previous_session);

 merge_session = qof_session_new();
 mergeBook = qof_session_get_book(merge_session);

This line seg_faults:
 list = gnc_load_example_account_list (mergeBook, locale_dir);

This one doesn't seg_fault (but doesn't work with the merge either).
 list = gnc_load_example_account_list (targetBook, locale_dir);

I've traced the seg fault all the way down to the XML parser:
    xmlParseDocument( ctxt->data.saxParserCtxt );
(which doesn't really help me much!)

Is something wrong with mergeBook?

Alternatively, is it just the example account format?
I can load normal GnuCash data files via a second session - I've done that 
with the previous example - just not these example files. Can I convert each 
example into a QofBook? If I convert and save each one as a .gnc instead of 
gnucash-xea? I'd have the 'problem' of allowing more than one set to be 
imported but I've already got the merge code to do that (and it can be done 
non-interactively at that stage). If that works, I could also change 
druid-hierarchy to use the same format.

Or is it a simple fix in the example code, somewhere?


Neil Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the gnucash-devel mailing list