Report development without the need to restart GnuCash

Charles Day cedayiv at gmail.com
Tue May 27 18:18:11 EDT 2008


On Tue, May 27, 2008 at 8:15 AM, Derek Atkins <warlord at mit.edu> wrote:

> "Charles Day" <cedayiv at gmail.com> writes:
>
> > On Tue, May 27, 2008 at 7:44 AM, Derek Atkins <warlord at mit.edu> wrote:
> >
> >     "Torsten Edeler" <torsten at edeler.org> writes:
> >
> >     > I'm not very sure, if I just created a memory leak.... On every
> call to
> >     > options-generator the function gnc:new-options is called twice.
> Once
> >     outside
> >     > and once inside the myoptions function. I hope Scheme has some kind
> of
> >     > garbage collection to handle this.
> >
> >     It does.
> >
> > Derek, do you agree that there is a bug in the reporting API, namely that
> it
> > will not catch exceptions that occur in Torsten's custom options
> generator?
> > (It does catch any exception occurring in his custom renderer.)
>
> Oh, maybe.  It's certainly arguable.  On the other hand, it's
> pretty hard to mess up your options-generator!  That's a pretty
> darn easy procedure to get right.
>
> > If so, should Torsten file a bug report? I tried looking for an existing
> bug
> > that covers this, but couldn't find one.
>
> Are you planning to fix it?
>

How about the following?  I tested by mangling the cash flow report's
options generator, and the problem was detected. A backtrace is generated,
an error is logged to the trace file, and the user sees the usual "An error
has occurred" in the report window. (Note: The last change corrects a
genuine bug, which I assume was just a typo of "names" vs. "namer".)

I would go ahead and commit this, Derek, but since I'm a reporting API noob,
perhaps you'd like to take a look first? (Assuming you agree in principle
with this change.)

-Charles


$ svn diff
Index: src/report/report-system/report.scm
===================================================================
--- src/report/report-system/report.scm (revision 17174)
+++ src/report/report-system/report.scm (working copy)
@@ -253,13 +253,19 @@
            (gnc:get-html-style-sheets)))))

     (if (procedure? generator)
-        (let ((options (generator)))
+        (let ((options (gnc:backtrace-if-exception generator)))
+          (if (not options)
+              (begin
+                (gnc:warn "BUG DETECTED: exception raised in "
+                          "report options generator procedure named "
+                          (procedure-name generator))
+                (set! options (gnc:new-options))))
           (gnc:register-option options stylesheet)
           (gnc:register-option options namer)
           options)
         (let ((options (gnc:new-options)))
            (gnc:register-option options stylesheet)
-          (gnc:register-option options names)
+          (gnc:register-option options namer)
           options))))

 ;; A <report> represents an instantiation of a particular report type.




> Honestly, I'd consider this a "developer issue", not a "user issue".
> Those dont really need bug reports, per se.
>
> > -Charles
>
> -derek
>
> --
>       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>       Member, MIT Student Information Processing Board  (SIPB)
>       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>       warlord at MIT.EDU                        PGP key available
>


More information about the gnucash-user mailing list