annoying simple Guile question

Neil Williams linux at
Tue Sep 21 19:53:51 EDT 2004

On Tuesday 21 September 2004 9:11 pm, you wrote:
> Neil Williams <linux at> writes:
> Uh, how/why are you using OpenSP?  It looks like OpenSP has an exit
> handler (via atexit()) which seems to be trying to flush a stream
> and hanging during a malloc call.

I'll look into that. TBH, I'm not sure why it is calling OpenSP, except that 
it is loading the current XML datasource files directly, without user 
intervention and without using Guile/Scheme/GUI.

The reason that this looks odd is because it started as a test program but has 
developed into somewhat of an interactive demo for the merge operations. The 
external files are new and the program needs to be put elsewhere. I'm hoping 
that the program will develop into a console tool to allow QofBook*s to be 
merged at the command line - using the GnuCash/QOF code but without the GUI. 
This could be useful for creating a pilot-link conduit for the final stage of 
the automation for generating invoices direct from a Palm (which is why I 
started this!). It may have other uses too.

Is a console demo/program/merge suitable for the main GnuCash tree?
Should it go in a new /examples or perhaps in /accounts?
Should it be outside GnuCash entirely, perhaps a mini project or absorbed 
completely into pilot-link?

(I don't mind which, except that if it is outside GnuCash completely, it might 
make it harder to get it working when the XML backend is replaced - it'd lose 
the automation and have to save the XML to the filesystem for a later merge 
within GnuCash itself.)

I find it quite a useful debugging tool (quicker to recompile and test than 
the full GUI).

I do have a more 'standardised' test routine that has none of these problems, 
mainly because it isn't interactive and therefore doesn't abort nor load 
external files.

> Very odd -- you must be doing something different than GnuCash.

Console interactivity is probably to blame.

> Strangely, none of the other test programs have this problem, so I'd
> start looking at how you're being different than those.  I'd start
> with the tests in the file backend.
> I'll also note that you might have a dependency issue if you're trying
> to "load files" from src/engine/test.

Agreed. It's become too different to be in the current location.

Pity, I've *almost* got the replacement patch ready that includes the Glade 
and C code to wrap a QofBook* merge operation around an existing file and the 
output of the hierarchy druid! It works (with a few provisos) but now I'll 
have to either fix or remove the example before I submit the patch.

I've got all day tomorrow to sort it out - if it doesn't work I'll submit the 
patch tomorrow evening (BST) without it.

The code itself is at:

qof_book_merge Source Code.
     * qof_book_merge.c
     * qof_book_merge.h
* Test and example programs. This test file shows an implementation of the 
qof_book_merge API:
       * test-book-merge.c
       This example files shows an interactive console implementation using 
GnuCash objects:
          + The example now uses external XML files as data sources:
            * druid-business.gnc
            * druid-simple.gnc
            These are simple GnuCash files, created using the New File druid.
     * A GUI example is available - to allow the New Account Hierarchy druid 
to be run over an existing file.
          + druid-merge.c - small changes required to window-main.c to allow 
for a menu item to call the druid.
            * - the Glade code to describe the druid resource.

Known problems with the merge druid so far:

1. First time crashes: For some reason, the first time you select a category, 
the code can cause a seg fault (in the hierarchy druid) - maybe 10% of the 
time. Next time you choose the same category, it works perfectly.

2. My GUI skills aren't the best so the druid behaviour is not ideal.

3. It's getting confused with the hierarchy druid output. Say you have a 
simple book open in GnuCash and select Childcare Expenses from the hierarchy 
druid to merge into your file. That's two accounts, Expenses (which will 
match an existing account) and Childcare. In the GUI, I get 63 collision 
Running the same files through the console application (I said it was handy!) 
generates the expected: 1 duplicate account, 1 possibly new account.
Some of the collision reports list parameter data for Account objects that is 
clearly inherited from UNSELECTED accounts from the example list - they 
neither exist in the original book nor the selection from the druid. I'm 
going to have to investigate delete_merge_group because it doesn't seem to be 
cleaning up properly (or else it's relying on a secondary process to do the 
clean up that is not called in the merge druid code).

4. I've got some work to do with memory and g_free - the druid currently 
crashes if you run it twice within one GnuCash instance.


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