Correctly set value of a GncOptionMultichoiceValue.

Accounting for the 3 types of SCM object that we might be handed.
This commit is contained in:
John Ralls 2021-02-19 13:50:13 -08:00
parent 7c1b4b794a
commit 16a36d9104

View File

@ -556,6 +556,23 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
} }
return; return;
} }
if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
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<std::decay_t<decltype(option.get_value())>>(new_value)); option.set_value(scm_to_value<std::decay_t<decltype(option.get_value())>>(new_value));
}, swig_get_option($self)); }, swig_get_option($self));
} }