From 16a36d91044b00ef653073bdb7ed193a992b3de3 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 19 Feb 2021 13:50:13 -0800 Subject: [PATCH] Correctly set value of a GncOptionMultichoiceValue. Accounting for the 3 types of SCM object that we might be handed. --- libgnucash/app-utils/gnc-optiondb.i | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 89e0e81227..d07ebefcdd 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -556,6 +556,23 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); } return; } + if constexpr (std::is_same_v, + GncOptionMultichoiceValue>) + { + if (scm_is_integer(new_value)) + { + option.set_value(scm_to_int(new_value)); + return; + } + std::string new_value_str{}; + if (scm_is_symbol(new_value)) + new_value_str = scm_to_utf8_string(scm_symbol_to_string(new_value)); + else if (scm_is_string(new_value)) + new_value_str = scm_to_utf8_string(new_value); + if (!new_value_str.empty()) + option.set_value(new_value_str); + return; + } option.set_value(scm_to_value>(new_value)); }, swig_get_option($self)); }