[Gnucash-changes] r13877 - gnucash/trunk - Don't load a custom report that has the same name as a standard

David Hampton hampton at cvs.gnucash.org
Sat Apr 29 03:27:45 EDT 2006


Author: hampton
Date: 2006-04-29 03:27:45 -0400 (Sat, 29 Apr 2006)
New Revision: 13877
Trac: http://svn.gnucash.org/trac/changeset/13877

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/report/report-system/report.scm
Log:
Don't load a custom report that has the same name as a standard
report.  Fixes #168250.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-04-29 07:25:53 UTC (rev 13876)
+++ gnucash/trunk/ChangeLog	2006-04-29 07:27:45 UTC (rev 13877)
@@ -1,5 +1,8 @@
 2006-04-29  David Hampton  <hampton at employees.org>
 
+	* src/report/report-system/report.scm: Don't load a custom report
+	that has the same name as a standard report.  Fixes #168250.
+
 	* src/bin/gnucash-bin.c: Load the user config earlier in startup.
 	Fixes the missing custom report problem #338668.
 

Modified: gnucash/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm	2006-04-29 07:25:53 UTC (rev 13876)
+++ gnucash/trunk/src/report/report-system/report.scm	2006-04-29 07:27:45 UTC (rev 13877)
@@ -92,14 +92,23 @@
   (let ((report-rec (args-to-defn #f args)))
     (if (and report-rec
              (gnc:report-template-name report-rec))
-        (hash-set! *gnc:_report-templates_*
-                   (gnc:report-template-name report-rec) report-rec)
+	(let* ((name (gnc:report-template-name report-rec))
+	       (tmpl (hash-ref *gnc:_report-templates_* name)))
+	  (if (not tmpl)
+	      (hash-set! *gnc:_report-templates_*
+			 (gnc:report-template-name report-rec) report-rec)
+	      (begin
+		(gnc:error (_ "Refusing to add custom report with the same name as an existing report."))
+		(gnc:error (_ "Please edit your saved-reports file and delete the section for: ") name)
+		)))
         (gnc:warn "gnc:define-report: bad report"))))
 
 (define gnc:report-template-version
   (record-accessor <report-template> 'version))
 (define gnc:report-template-name
   (record-accessor <report-template> 'name))
+(define gnc:report-template-set-name
+  (record-modifier <report-template> 'name))
 (define gnc:report-template-options-generator
   (record-accessor <report-template> 'options-generator))
 (define gnc:report-template-options-cleanup-cb



More information about the gnucash-changes mailing list