r23159 - gnucash/trunk/src/report/report-system - Prevent 2.4 from crashing when loading a book that was opened with 2.6 before.

Geert Janssens gjanssens at code.gnucash.org
Wed Sep 4 08:55:50 EDT 2013


Author: gjanssens
Date: 2013-09-04 08:55:49 -0400 (Wed, 04 Sep 2013)
New Revision: 23159
Trac: http://svn.gnucash.org/trac/changeset/23159

Modified:
   gnucash/trunk/src/report/report-system/report.scm
Log:
Prevent 2.4 from crashing when loading a book that was opened with 2.6 before.

The core issue is that open reports are using a new restore function in 2.6,
which doesn't exist in 2.4 and older. The restore code now checks for the
existence of this new function and falls back to the old one if necessary.
The (mild) side effect is that in 2.4 any link to a custom template is lost.

Modified: gnucash/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm	2013-09-03 14:02:35 UTC (rev 23158)
+++ gnucash/trunk/src/report/report-system/report.scm	2013-09-04 12:55:49 UTC (rev 23159)
@@ -525,12 +525,24 @@
     #f "(let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
     (gnc:report-type report) (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
    (gnc:generate-restore-forms (gnc:report-options report) "options")
+   ;; 2.6->2.4 compatibility code prefix
+   ;; Temporary check to make the new report saving code more or less backwards
+   ;; compatible with older gnucash versions. This can be removed again in 2.8.
+   "(if (defined? 'gnc:restore-report-by-guid-with-custom-template)\n"
+    ;; end of 2.6->2.4 compatibility code prefix.
    (format 
-    #f "  (gnc:restore-report-by-guid-with-custom-template ~S ~S ~S ~S options))\n"
+    #f "  (gnc:restore-report-by-guid-with-custom-template ~S ~S ~S ~S options)\n"
     (gnc:report-id report) (gnc:report-type report)
     (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report)))
-    (gnc:report-custom-template report)
-  )))
+    (gnc:report-custom-template report))
+   ;; 2.6->2.4 compatibility code suffix
+   (format 
+    #f "  (gnc:restore-report-by-guid ~S ~S ~S options))\n"
+    (gnc:report-id report) (gnc:report-type report)
+    (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
+    ;; end of 2.6->2.4 compatibility code suffix.
+   ")"
+  ))
 
 ;; Loop over embedded reports and concat result of each gnc:report-generate-restore-forms
 (define (gnc:report-generate-options-embedded report)



More information about the gnucash-changes mailing list