r18404 - gnucash/trunk/src/app-utils - Bug #599953: Let gnc:make-[complex|simple]-boolean-option store its value as a string
Christian Stimming
cstim at code.gnucash.org
Sat Oct 31 17:03:40 EDT 2009
Author: cstim
Date: 2009-10-31 17:03:40 -0400 (Sat, 31 Oct 2009)
New Revision: 18404
Trac: http://svn.gnucash.org/trac/changeset/18404
Modified:
gnucash/trunk/src/app-utils/options.scm
Log:
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).
Modified: gnucash/trunk/src/app-utils/options.scm
===================================================================
--- gnucash/trunk/src/app-utils/options.scm 2009-10-31 21:03:25 UTC (rev 18403)
+++ gnucash/trunk/src/app-utils/options.scm 2009-10-31 21:03:40 UTC (rev 18404)
@@ -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)
More information about the gnucash-changes
mailing list