Multiple QofBook support working

Derek Atkins warlord at MIT.EDU
Wed Sep 15 14:29:26 EDT 2004


Neil Williams <linux at> writes:

> 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.

Note that druid-hierarchy uses a different file reader than the
standard file-load code path.  I haven't actually looked at the new
hierarchy code so I don't know exactly how it works.  But my
understanding was that it wouldn't actually create a populated book
until the user says "ok".

> 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. 

This should be possible provided that the druid code never uses an
implicit book.  Indeed, our first objective here should be to remove
as many calls to qof_session_get_current_session() as possible, and
then pass down explicity Session and/or Book objects.

> 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 *).

Why make a copy of the code?  Or is this only for testing purposes?  I
would think that you could share a good 90% (or more) of code with the
current hierarchy druid.

> Using:
>  previous_session = qof_session_get_current_session();
>  targetBook = qof_session_get_book(previous_session);
>  merge_session = qof_session_new();
>  qof_session_set_current_session(merge_session);
>  mergeBook = qof_session_get_book(merge_session);
> This line seg_faults:
>  list = gnc_load_example_account_list (mergeBook, locale_dir);

What's the backtrace of the segv?  You _ARE_ running this under gdb,

> 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!)

Well, what's ctxt look like?

> Is something wrong with mergeBook?

I dont know, you tell me.  Does it look right to you?

> 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?

I don't know..  I haven't looked.

First thing to look at is anything that might assume the 'default
session' or 'default book'.  The next thing to try is following the
stack trace and make sure you're loading and initializing everything


PS: Sorry I haven't committed your last patch -- I had a family
emergency to deal with and right now I'm battling a fever.  I probably
shouldn't even be on the 'puter right now.

Good Luck.

       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL:    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available

More information about the gnucash-devel mailing list