[Gnucash-changes] r12989 - gnucash/trunk/src/report - Check for invalid options tables when loading reports.

Chris Shoemaker chris at cvs.gnucash.org
Fri Jan 27 01:15:33 EST 2006


Author: chris
Date: 2006-01-27 01:15:31 -0500 (Fri, 27 Jan 2006)
New Revision: 12989
Trac: http://svn.gnucash.org/trac/changeset/12989

Modified:
   gnucash/trunk/src/report/report-gnome/window-report.c
   gnucash/trunk/src/report/report-system/report.scm
Log:
   Check for invalid options tables when loading reports.
   Also, plug memory leak in my last commit.


Modified: gnucash/trunk/src/report/report-gnome/window-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.c	2006-01-27 05:27:08 UTC (rev 12988)
+++ gnucash/trunk/src/report/report-gnome/window-report.c	2006-01-27 06:15:31 UTC (rev 12989)
@@ -323,7 +323,13 @@
 remove_invalid_report(gpointer key, gpointer val, gpointer data)
 {
     SCM report = val;
-    return (NULL == gnc_report_name(report));
+    gchar *name = NULL;
+
+    if (NULL == (name = gnc_report_name(report)))
+        return TRUE;
+
+    g_free(name);
+    return FALSE;
 }
 
 static void

Modified: gnucash/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm	2006-01-27 05:27:08 UTC (rev 12988)
+++ gnucash/trunk/src/report/report-system/report.scm	2006-01-27 06:15:31 UTC (rev 12989)
@@ -269,7 +269,7 @@
     (if (>= id *gnc:_report-next-serial_*)
         (set! *gnc:_report-next-serial_* (+ id 1)))
     (gnc:report-add id r)
-    id))
+    #f))
 
 
 (define (gnc:make-report-options template-name)
@@ -305,9 +305,11 @@
         #f)))
 
 (define (gnc:report-name report) 
-  (gnc:option-value
-   (gnc:lookup-option (gnc:report-options report)
-                      gnc:pagename-general gnc:optname-reportname)))
+  (let* ((opt (gnc:report-options report)))
+    (if opt
+        (gnc:option-value
+         (gnc:lookup-option opt gnc:pagename-general gnc:optname-reportname))
+        #f)))
 
 (define (gnc:report-stylesheet report)
   (gnc:html-style-sheet-find 
@@ -340,9 +342,8 @@
 (define (gnc:report-generate-restore-forms report)
   ;; clean up the options if necessary.  this is only needed 
   ;; in special cases.  
-  (let* ((template 
-          (hash-ref  *gnc:_report-templates_* 
-                     (gnc:report-type report)))
+  (let* ((report-type (gnc:report-type report))
+         (template (hash-ref *gnc:_report-templates_* report-type))
          (thunk (gnc:report-template-options-cleanup-cb template)))
     (if thunk 
         (thunk report)))



More information about the gnucash-changes mailing list