r16977 - gnucash/branches/2.2/src - [r16836] Prevent crashing when a report template disappears (#505921).
Andreas Köhler
andi5 at cvs.gnucash.org
Fri Feb 29 16:00:09 EST 2008
Author: andi5
Date: 2008-02-29 16:00:08 -0500 (Fri, 29 Feb 2008)
New Revision: 16977
Trac: http://svn.gnucash.org/trac/changeset/16977
Modified:
gnucash/branches/2.2/src/app-utils/options.scm
gnucash/branches/2.2/src/report/report-system/report.scm
Log:
[r16836] 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.
Committed by andrewsw.
Modified: gnucash/branches/2.2/src/app-utils/options.scm
===================================================================
--- gnucash/branches/2.2/src/app-utils/options.scm 2008-02-28 22:50:39 UTC (rev 16976)
+++ gnucash/branches/2.2/src/app-utils/options.scm 2008-02-29 21:00:08 UTC (rev 16977)
@@ -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))
Modified: gnucash/branches/2.2/src/report/report-system/report.scm
===================================================================
--- gnucash/branches/2.2/src/report/report-system/report.scm 2008-02-28 22:50:39 UTC (rev 16976)
+++ gnucash/branches/2.2/src/report/report-system/report.scm 2008-02-29 21:00:08 UTC (rev 16977)
@@ -282,16 +282,24 @@
;; 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>)
- template-name id options #t #t #f #f)))
- (gnc-report-add r))
+ (if options
+ (let ((r ((record-constructor <report>)
+ 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))
)
;; dummy function to enable backwards compatibility with newer reports
(define (gnc:restore-report-by-guid id template-id template-name options)
- (gnc:restore-report id template-name options))
+ (if options
+ (gnc:restore-report id template-name options)
+ (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)
(let ((template (hash-ref *gnc:_report-templates_* template-name)))
(if template
More information about the gnucash-changes
mailing list