AUDIT: r16836 - gnucash/trunk/src - Prevent crashing when a report template disappears (#505921).
Andrew Sackville-West
andrewsw at cvs.gnucash.org
Sun Jan 6 18:55:48 EST 2008
Author: andrewsw
Date: 2008-01-06 18:55:48 -0500 (Sun, 06 Jan 2008)
New Revision: 16836
Trac: http://svn.gnucash.org/trac/changeset/16836
Modified:
gnucash/trunk/src/app-utils/options.scm
gnucash/trunk/src/report/report-system/report.scm
Log:
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
Modified: gnucash/trunk/src/app-utils/options.scm
===================================================================
--- gnucash/trunk/src/app-utils/options.scm 2008-01-06 22:27:57 UTC (rev 16835)
+++ gnucash/trunk/src/app-utils/options.scm 2008-01-06 23:55:48 UTC (rev 16836)
@@ -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/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm 2008-01-06 22:27:57 UTC (rev 16835)
+++ gnucash/trunk/src/report/report-system/report.scm 2008-01-06 23:55:48 UTC (rev 16836)
@@ -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)
More information about the gnucash-changes
mailing list