From 9bd3baff63d41186aff4f3341f6373098d19e1fd Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 25 Feb 2021 10:40:18 -0800 Subject: [PATCH] Change the reldate_values alist from a static to a singleton. A static has to be initialized at library load and Guile isn't necessarily running then. The singleton gets evaluated at runtime only if the getter is called from Guile. --- libgnucash/app-utils/gnc-optiondb.i | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 65d0b2a4de..40ac774838 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -464,7 +464,12 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); %typemap(out) GncOption* "$result = ($1) ? scm_from_pointer($1, nullptr) : SCM_BOOL_F;" %header %{ - static const SCM reldate_values = scm_c_eval_string( + static const SCM get_reldate_values() { + + static SCM reldate_values = SCM_BOOL_F; + + if (scm_is_false(reldate_values)) + reldate_values = scm_c_eval_string( "'((absolute RelativeDatePeriod-ABSOLUTE)" "(today RelativeDatePeriod-TODAY)" "(one-week-ago RelativeDatePeriod-ONE-WEEK-AGO)" @@ -626,7 +631,8 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); { if (!$self) return; - std::visit([new_value](auto& option) { + auto reldate_values{get_reldate_values()}; + std::visit([new_value, reldate_values](auto& option) { if constexpr (std::is_same_v, GncOptionDateValue>) {