mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
This commit is contained in:
parent
189b1186bd
commit
4b9981e127
@ -445,9 +445,18 @@
|
|||||||
(setter-function-called-cb x)))
|
(setter-function-called-cb x)))
|
||||||
(lambda () default-value)
|
(lambda () default-value)
|
||||||
(gnc:restore-form-generator value->string)
|
(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)
|
(lambda (f p)
|
||||||
(let ((v (kvp-frame-get-slot-path-gslist 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)))
|
(if (and v (boolean? v) (not (equal? v default-value)))
|
||||||
(set! value v))))
|
(set! value v))))
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
|
Loading…
Reference in New Issue
Block a user