diff options
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -621,9 +621,29 @@ unsigned int read_binary_journal(std::istream& in, std::pair<base_commodities_map::iterator, bool> result = commodity_base_t::commodities.insert (base_commodities_pair(commodity->symbol, commodity)); - if (! result.second) - throw error(std::string("Failed to read base commodity from cache: ") + - commodity->symbol); + if (! result.second) { + base_commodities_map::iterator c = + commodity_base_t::commodities.find(commodity->symbol); + + // It's possible the user might have used a commodity in a value + // expression passed to an option, we'll just override the + // flags, but keep the commodity pointer intact. + if (c == commodity_base_t::commodities.end() || + (*c).second->history || (*c).second->smaller || + (*c).second->larger) + throw new error(std::string("Failed to read base commodity from cache: ") + + commodity->symbol); + + (*c).second->name = commodity->name; + (*c).second->note = commodity->note; + (*c).second->precision = commodity->precision; + (*c).second->flags = commodity->flags; + (*c).second->history = commodity->history; + (*c).second->smaller = commodity->smaller; + (*c).second->larger = commodity->larger; + + *(base_commodities_next - 1) = (*c).second; + } } for (commodity_base_t::ident_t i = 0; i < bc_count; i++) @@ -655,9 +675,9 @@ unsigned int read_binary_journal(std::istream& in, std::pair<commodities_map::iterator, bool> result = commodity_t::commodities.insert(commodities_pair(mapping_key, commodity)); - if (! result.second) - throw error(std::string("Failed to read commodity from cache: ") + - commodity->ptr->symbol); + if (! result.second && commodity->annotated) + throw new error(std::string("Failed to read commodity from cache: ") + + commodity->ptr->symbol); } commodity_t::ident_t ident; |