Skip to content

Commit

Permalink
Bug 799148 - Reliable crash when saving a modified saved report...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
christopherlam authored and jralls committed Dec 16, 2023
1 parent 1da2464 commit 9d15e70
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions gnucash/report/report-core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,14 @@ not found.")))
(define (gnc:report-template-serialize report-template)
(let* ((name (gnc:report-template-name report-template))
(type (gnc:report-template-parent-type report-template))
(templ-name (gnc:report-template-name
(hash-ref *gnc:_report-templates_* type)))
(options (gnc:report-template-new-options report-template))
(guid (gnc:report-template-report-guid report-template)))
(gnc:report-template-serialize-internal name type templ-name options guid)))
(tmpl (hash-ref *gnc:_report-templates_* type)))
(cond
((not tmpl) (gnc:warn "gnc:report-template-serialize: cannot find template for " type) #f)
(else
(let ((templ-name (gnc:report-template-name tmpl))
(options (gnc:report-template-new-options report-template))
(guid (gnc:report-template-report-guid report-template)))
(gnc:report-template-serialize-internal name type templ-name options guid))))))

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

(define (gnc:report-template-save-to-savefile report-template)
(let ((saved-form (gnc:report-template-serialize report-template)))
(gnc-saved-reports-write-to-file saved-form #f)))
(and saved-form (gnc-saved-reports-write-to-file saved-form #f))))

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

0 comments on commit 9d15e70

Please sign in to comment.