gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Fri Dec 3 19:25:16 EST 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/d740ac1c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5a812ca1 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a85520de (commit)



commit d740ac1cb0d06bae632e508fb8360a7ada221a96
Merge: a85520de7 5a812ca1e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 4 08:24:10 2021 +0800

    Merge branch 'budget-option-stores-guid' into maint PR #1207


commit 5a812ca1eb9d13896ed1fc43ea207414b8a041ce
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 4 01:36:08 2021 +0800

    [options.scm] gnc:make-budget-option stores guid instead of object
    
    because object may become stale if UI is used to delete it, leading to
    stale pointer and segfault. storing guid is safer, and will return
    null if budget is deleted.

diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index 8481572cb..dbc4e0b5c 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -470,6 +470,13 @@ the option '~a'."))
 	 (selection-budget initial-budget)
          )
 
+
+    (define (convert-to-guid item)
+      (if (string? item) item (gncBudgetGetGUID item)))
+
+    (define (convert-to-budget item)
+      (if (string? item) (gnc-budget-lookup item (gnc-get-current-book)) item))
+
     (gnc:make-option
      section 
      name 
@@ -478,12 +485,12 @@ the option '~a'."))
      documentation-string
 
      ;; getter -- Return a budget pointer
-     (lambda () 
-       selection-budget)
+     (lambda ()
+       (convert-to-budget selection-budget))
 
      ;; setter -- takes a budget
      (lambda (x)
-       (set! selection-budget x))
+       (set! selection-budget (convert-to-guid x)))
 
      ;; default-getter
      ;; Default now is #f so saving is independent of book-level default



Summary of changes:
 libgnucash/app-utils/options.scm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list