From 4b9981e127aac8005193054a03f808c97bcbc454 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 31 Oct 2009 21:03:40 +0000 Subject: [PATCH] Bug #599953: Let gnc:make-[complex|simple]-boolean-option store its value as a string Patch by Mike Alexander (plus documentation comment by me): Neither gnc:make-complex-boolean-option nor gnc:make-simple-boolean-option (which calls it) correctly stores its result in the KVP that it is using. This is because it calls kvp-frame-get-slot-path-gslist and kvp-frame-set-slot-path-gslist to get and set the value. Both of these are implemented in C and the code in kvp-scm.c can't convert a Scheme boolean value to or from a KvpValue since there is no boolean type in KvpValue. There are already a few places that have comments suggesting that there should be a KVP_TYPE_BOOLEAN type, but adding this would be non-trivial. For now I'll supply a patch that will store the boolean value as a string (which is what code in xaccAccountSetAutoInterestXfer in Account.c does). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18404 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-utils/options.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app-utils/options.scm b/src/app-utils/options.scm index 1885eca20e..3f39619906 100644 --- a/src/app-utils/options.scm +++ b/src/app-utils/options.scm @@ -445,9 +445,18 @@ (setter-function-called-cb x))) (lambda () default-value) (gnc:restore-form-generator value->string) - (lambda (f p) (kvp-frame-set-slot-path-gslist f value p)) + (lambda (f p) (kvp-frame-set-slot-path-gslist f + ;; As no boolean KvpValue exists, as a workaround + ;; we store the string "t" for TRUE and "f" for + ;; FALSE in a string KvpValue. + (if value "t" "f") + p)) (lambda (f p) (let ((v (kvp-frame-get-slot-path-gslist f p))) + ;; As no boolean KvpValue exists, as a workaround we store + ;; the string "t" for TRUE and "f" for FALSE. + (cond ((equal? v "t") (set! v #t)) + ((equal? v "f") (set! v #f))) (if (and v (boolean? v) (not (equal? v default-value))) (set! value v)))) (lambda (x)