This partly fixes the currency and commodity combos

With these changes the currency works but the commodity allows you to
set the commodity but will crash if you save config or leave report
open, this was tested on the 'Price scatter plot' report. Fixed with
John's commit a8e6a59
pull/1317/head
Robert Fewell 4 years ago
parent c6dff82b12
commit ee7ed89b68

@ -976,15 +976,16 @@ public:
void set_ui_item_from_option(GncOption& option) noexcept override
{
auto widget{GNC_CURRENCY_EDIT(get_widget())};
auto instance{option.get_value<const QofInstance*>()};
if (instance)
gnc_currency_edit_set_currency(widget, GNC_COMMODITY(instance));
auto currency{option.get_value<gnc_commodity*>()};
if (currency)
gnc_currency_edit_set_currency(widget, GNC_COMMODITY(currency));
}
void set_option_from_ui_item(GncOption& option) noexcept override
{
auto widget{GNC_CURRENCY_EDIT(get_widget())};
auto currency = gnc_currency_edit_get_currency(widget);
option.set_value(qof_instance_cast(currency));
option.set_value<gnc_commodity*>(currency);
}
};
@ -1016,15 +1017,16 @@ public:
void set_ui_item_from_option(GncOption& option) noexcept override
{
auto widget{GNC_GENERAL_SELECT(get_widget())};
auto instance{option.get_value<const QofInstance*>()};
if (instance)
gnc_general_select_set_selected(widget, GNC_COMMODITY(instance));
auto commodity{option.get_value<gnc_commodity*>()};
if (commodity)
gnc_general_select_set_selected(widget, GNC_COMMODITY(commodity));
}
void set_option_from_ui_item(GncOption& option) noexcept override
{
auto widget{GNC_GENERAL_SELECT(get_widget())};
auto commodity{gnc_general_select_get_selected(widget)};
option.set_value(qof_instance_cast(commodity));
option.set_value<gnc_commodity*>(GNC_COMMODITY(commodity));
}
};

@ -224,7 +224,7 @@ GncOptionCommodityValue::reset_default_value()
bool
GncOptionCommodityValue::is_changed() const noexcept
{
return m_namespace == m_default_namespace && m_mnemonic == m_default_mnemonic;
return m_namespace != m_default_namespace || m_mnemonic != m_default_mnemonic;
}
bool

@ -1346,8 +1346,7 @@ inline SCM return_scm_value(ValueType value)
if (scm_is_string(new_value))
{
auto strval{scm_to_utf8_string(new_value)};
auto val{qof_instance_from_string(strval, option.get_ui_type())};
option.set_value(GNC_COMMODITY(val));
option.deserialize(strval);
return;
}
option.set_value(scm_to_value<gnc_commodity*>(new_value));

Loading…
Cancel
Save