Prevent crashing when a report template disappears (#505921).

If a report template is missing (renamed, moved, deleted, whatever)
while the report is still open, then the app will crash while reading
the books file. The options-generator will fail and cause subsequent
attempts to access the options to fail and crash. A couple checks for
the existence of options is all it takes. Also included a warning dialog.

BP


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16836 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andrew Sackville-West 2008-01-06 23:55:48 +00:00
parent 7feab49362
commit 8bad06ceeb
2 changed files with 17 additions and 7 deletions

View File

@ -1464,7 +1464,9 @@
((options 'for-each-general) section-thunk option-thunk))
(define (gnc:lookup-option options section name)
((options 'lookup) section name))
(if options
((options 'lookup) section name)
#f))
(define (gnc:generate-restore-forms options options-string)
((options 'generate-restore-forms) options-string))

View File

@ -356,15 +356,23 @@
;; This is the function that is called when saved reports are evaluated.
(define (gnc:restore-report id template-name options)
(let ((r ((record-constructor <report>)
(gnc:report-template-name-to-id template-name) id options #t #t #f #f)))
(gnc-report-add r))
(if options
(let ((r ((record-constructor <report>)
(gnc:report-template-name-to-id template-name) id options #t #t #f #f)))
(gnc-report-add r))
(begin
(gnc-error-dialog '() (string-append "Report Failed! One of your previously opened reports has failed to open. The template on which it was based: " template-name ", was not found."))
#f))
)
(define (gnc:restore-report-by-guid id template-id template-name options)
(let ((r ((record-constructor <report>)
template-id id options #t #t #f #f)))
(gnc-report-add r))
(if options
(let ((r ((record-constructor <report>)
template-id id options #t #t #f #f)))
(gnc-report-add r))
(begin
(gnc-error-dialog '() (string-append "Report Failed! One of your previously opened reports has failed to open. The template on which it was based: " template-name ", was not found."))
#f))
)
(define (gnc:make-report-options template-name)