mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[report] convert (gnc:restore-report) to use closure
Instead of a global variable gnc:old-style-restore-warned, use closure to isolate variable within the only function which uses it.
This commit is contained in:
parent
6e7cd33308
commit
d49a51ca73
@ -885,22 +885,21 @@ not found.")))
|
|||||||
*gnc:_report-templates_*)
|
*gnc:_report-templates_*)
|
||||||
template-id))
|
template-id))
|
||||||
|
|
||||||
;; We want to warn users when we are trying to restore reports stored in the legacy
|
|
||||||
;; format (based on name instead of guid), but only once
|
|
||||||
(define gnc:old-style-restore-warned #f)
|
|
||||||
|
|
||||||
;; Legacy: this function is needed only to restore
|
;; Legacy: this function is needed only to restore
|
||||||
;; a saved report when loading a book last saved in GnuCash 2.2
|
;; a saved report when loading a book last saved in GnuCash 2.2
|
||||||
(define (gnc:restore-report id template-name options)
|
(define gnc:restore-report
|
||||||
(if options
|
(let ((first-warn? #t))
|
||||||
(let ((r ((record-constructor <report>)
|
(lambda (id template-name options)
|
||||||
(gnc:report-template-name-to-id template-name) id options #t #t #f #f "")))
|
(cond
|
||||||
;; Warn user (one time) we're attempting to restore old style reports
|
(options
|
||||||
(if (not gnc:old-style-restore-warned)
|
(let* ((constructor (record-constructor <report>))
|
||||||
(begin
|
(template-id (gnc:report-template-name-to-id template-name))
|
||||||
(set! gnc:old-style-restore-warned #t)
|
(report (constructor template-id id options #t #t #f #f "")))
|
||||||
(gnc-warning-dialog '() rptwarn-legacy)))
|
;; Warn user (one time) we're attempting to restore old style reports
|
||||||
(gnc-report-add r))
|
(when first-warn?
|
||||||
(begin
|
(set! first-warn? #f)
|
||||||
|
(gui-warning rptwarn-legacy))
|
||||||
|
(gnc-report-add report)))
|
||||||
|
(else
|
||||||
(gui-error-missing-template template-name)
|
(gui-error-missing-template template-name)
|
||||||
#f)))
|
#f)))))
|
||||||
|
Loading…
Reference in New Issue
Block a user