Backwards compatibility with new currency issue and bug 336843.

Frédéric Perrin fred at fperrin.net
Tue Nov 19 17:38:23 EST 2013


Le mardi 19 à 23:05, Derek Atkins a écrit :
> On Tue, November 19, 2013 4:58 pm, Frédéric Perrin wrote:
>> Anyway, this is due to r23345 : since we set the user_symbol of every
>> currency at startup, the KVP of every currency, even those not used, now
>> contains simething. Therefore, in gnc_commodity_dom_tree_create(),
>> kvpnode is !NULL, and every currency gets dumped to the XML file at save
>> time. That includes the new ZMW, and when your old gnucash that doesn't
>> know about ZMW sees that currency, it aborts with "Invalid commodity".
>>
>> I suppose we don't want to dump every currency into the save file
>> whenever the file is written. Do we want to check currency->usage_count ?
>> Do we want an API Bool gnc_account_currency_used(Account, gnc_commodity) ?
>> Thoughts ?
>
> I would recommend we do something slightly different.  I would have TWO
> setter functions, a "set_default()" as well as a "set()".  The
> gnc_commodity object can be extended to cache the value.  The
> set_default() would only set the cached value.  The set() function would
> both set the cached value *and* set the kvp.  The get() function could
> first check the kvp() and, if that is empty or non-existing it can use the
> cached value.  Either that, or at load time we cache the value from the
> kvp if it exists and then get() only needs to read the cached value.

That would also limit the modifications to the commodity class, rather
tham having each backend checking whether the commodity is used.

The attached patch compiles and seems to do what we want from 5 minutes
of testing.

-- 
Fred
-------------- next part --------------
A non-text attachment was scrubbed...
Name: separate_default_user-set_symbol.patch
Type: text/x-patch
Size: 2319 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20131119/f13e8272/attachment.bin>


More information about the gnucash-devel mailing list