"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libgnucash/engine/gnc-option.cpp" between
gnucash-5.0.tar.bz2 and gnucash-5.1.tar.bz2

About: GnuCash is personal and small-business financial-accounting software.

gnc-option.cpp  (gnucash-5.0.tar.bz2):gnc-option.cpp  (gnucash-5.1.tar.bz2)
skipping to change at line 50 skipping to change at line 50
m_option{std::make_unique<GncOptionVariant>( m_option{std::make_unique<GncOptionVariant>(
std::in_place_type<GncOptionValue<ValueType>>, std::in_place_type<GncOptionValue<ValueType>>,
section, name, key, doc_string, value, ui_type)} section, name, key, doc_string, value, ui_type)}
{ {
} }
template <typename ValueType> ValueType template <typename ValueType> ValueType
GncOption::get_value() const GncOption::get_value() const
{ {
return std::visit( return std::visit(
[](const auto option)->ValueType { [](const auto& option)->ValueType {
if constexpr (is_same_decayed_v<decltype(option.get_value()), if constexpr (is_same_decayed_v<decltype(option.get_value()),
ValueType>) ValueType>)
return option.get_value(); return option.get_value();
if constexpr (is_same_decayed_v<decltype(option), if constexpr (is_same_decayed_v<decltype(option),
GncOptionDateValue>) GncOptionDateValue>)
{ {
if constexpr (is_same_decayed_v<ValueType, if constexpr (is_same_decayed_v<ValueType,
RelativeDatePeriod>) RelativeDatePeriod>)
return option.get_period(); return option.get_period();
if constexpr (std::is_same_v<ValueType, time64>) if constexpr (std::is_same_v<ValueType, time64>)
skipping to change at line 83 skipping to change at line 83
return option.get_multiple(); return option.get_multiple();
} }
return ValueType {}; return ValueType {};
}, *m_option); }, *m_option);
} }
template <typename ValueType> ValueType template <typename ValueType> ValueType
GncOption::get_default_value() const GncOption::get_default_value() const
{ {
return std::visit( return std::visit(
[](const auto option)->ValueType { [](const auto& option)->ValueType {
if constexpr (is_same_decayed_v<decltype(option.get_value()), if constexpr (is_same_decayed_v<decltype(option.get_value()),
ValueType>) ValueType>)
return option.get_default_value(); return option.get_default_value();
if constexpr (is_same_decayed_v<decltype(option), if constexpr (is_same_decayed_v<decltype(option),
GncOptionDateValue>) GncOptionDateValue>)
{ {
if constexpr (is_same_decayed_v<ValueType, if constexpr (is_same_decayed_v<ValueType,
RelativeDatePeriod>) RelativeDatePeriod>)
return option.get_default_period(); return option.get_default_period();
if constexpr (std::is_same_v<ValueType, time64>) if constexpr (std::is_same_v<ValueType, time64>)
skipping to change at line 224 skipping to change at line 224
} }
void void
GncOption::set_ui_item(GncOptionUIItemPtr&& ui_item) GncOption::set_ui_item(GncOptionUIItemPtr&& ui_item)
{ {
auto opt_ui_type = std::visit([](const auto& option)->GncOptionUIType { auto opt_ui_type = std::visit([](const auto& option)->GncOptionUIType {
return option.get_ui_type(); return option.get_ui_type();
}, *m_option); }, *m_option);
if (ui_item->get_ui_type() != opt_ui_type) //ui_item may be nullptr to free the old m_ui_item.
if (ui_item && ui_item->get_ui_type() != opt_ui_type)
{ {
PERR("Setting option %s:%s UI element failed, mismatched UI types.", PERR("Setting option %s:%s UI element failed, mismatched UI types.",
get_section().c_str(), get_name().c_str()); get_section().c_str(), get_name().c_str());
return; return;
} }
m_ui_item = std::move(ui_item); m_ui_item = std::move(ui_item);
} }
void void
 End of changes. 3 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)