From 8bad06ceeb004d0bc0351d0ba308a0f0070b6261 Mon Sep 17 00:00:00 2001 From: Andrew Sackville-West Date: Sun, 6 Jan 2008 23:55:48 +0000 Subject: [PATCH] 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 --- src/app-utils/options.scm | 4 +++- src/report/report-system/report.scm | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/app-utils/options.scm b/src/app-utils/options.scm index 4b132feee9..375411ac46 100644 --- a/src/app-utils/options.scm +++ b/src/app-utils/options.scm @@ -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)) diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm index cfd1f4457e..a6a5d8501e 100644 --- a/src/report/report-system/report.scm +++ b/src/report/report-system/report.scm @@ -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 ) - (gnc:report-template-name-to-id template-name) id options #t #t #f #f))) - (gnc-report-add r)) + (if options + (let ((r ((record-constructor ) + (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 ) - template-id id options #t #t #f #f))) - (gnc-report-add r)) + (if options + (let ((r ((record-constructor ) + 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)