Skip to content

Commit 9d15e70

Browse files
christopherlamjralls
authored andcommitted
Bug 799148 - Reliable crash when saving a modified saved report...
configuration. The user's saved configurations included some based on a bad report-id, so handle the hash table returning #f by skipping that configuration. There's an odd side-effect: The Save Configuration As action doesn't prepare the dialog to edit the saved configuration name, the user must find the new configuration and rename it. It works correctly if there are no discarded configurations.
1 parent 1da2464 commit 9d15e70

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gnucash/report/report-core.scm

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,11 +645,14 @@ not found.")))
645645
(define (gnc:report-template-serialize report-template)
646646
(let* ((name (gnc:report-template-name report-template))
647647
(type (gnc:report-template-parent-type report-template))
648-
(templ-name (gnc:report-template-name
649-
(hash-ref *gnc:_report-templates_* type)))
650-
(options (gnc:report-template-new-options report-template))
651-
(guid (gnc:report-template-report-guid report-template)))
652-
(gnc:report-template-serialize-internal name type templ-name options guid)))
648+
(tmpl (hash-ref *gnc:_report-templates_* type)))
649+
(cond
650+
((not tmpl) (gnc:warn "gnc:report-template-serialize: cannot find template for " type) #f)
651+
(else
652+
(let ((templ-name (gnc:report-template-name tmpl))
653+
(options (gnc:report-template-new-options report-template))
654+
(guid (gnc:report-template-report-guid report-template)))
655+
(gnc:report-template-serialize-internal name type templ-name options guid))))))
653656

654657
;; Convert a report into a report template and save this template in the savefile
655658
;; Under specific conditions the we will attempt to replace the current report's
@@ -712,7 +715,7 @@ not found.")))
712715

713716
(define (gnc:report-template-save-to-savefile report-template)
714717
(let ((saved-form (gnc:report-template-serialize report-template)))
715-
(gnc-saved-reports-write-to-file saved-form #f)))
718+
(and saved-form (gnc-saved-reports-write-to-file saved-form #f))))
716719

717720
;; save all custom reports, moving the old version of the
718721
;; saved-reports file aside as a backup

0 commit comments

Comments
 (0)