Properly save & restore empty values as well

This commit is contained in:
Boldizsár Lipka 2012-09-26 14:54:43 +00:00
parent 94e6847dc4
commit 4734d8de1e
2 changed files with 6 additions and 7 deletions

View File

@ -396,10 +396,9 @@ void manager::add_checkbox(const config& data, config& column) const
config& manager::get_value_cfg(const std::string& id)
{
{
const manager* m = this;
config& value_cfg = const_cast<config&>(m->get_value_cfg(id));
const config& value_cfg = get_value_cfg_or_empty(id);
if (!value_cfg.empty()) {
return value_cfg;
return const_cast<config&>(value_cfg);
}
}
@ -418,7 +417,7 @@ config& manager::get_value_cfg(const std::string& id)
return value_cfg;
}
const config& manager::get_value_cfg(const std::string& id) const
const config& manager::get_value_cfg_or_empty(const std::string& id) const
{
static const config empty;
@ -470,9 +469,9 @@ const config& manager::get_option_info_cfg(const std::string& id) const
config::attribute_value manager::get_stored_value(const std::string& id) const
{
const config& valcfg = get_value_cfg(id);
const config& valcfg = get_value_cfg_or_empty(id);
if (!valcfg["value"].empty()) {
if (!valcfg.empty()) {
// There's a saved value for this option
return valcfg["value"];
}

View File

@ -221,7 +221,7 @@ private:
* for this option should be written into or
* an empty config if that doesn't exist.
*/
const config& get_value_cfg(const std::string& id) const;
const config& get_value_cfg_or_empty(const std::string& id) const;
/**
* Returns the information about an option.