I have a question about how to treat old metadata. In particular when GnuCash 
is closed any 
open report is written to a meta file in .gnucash/books. Basically a report 
identifier and all 
modified options are stored.

Before GnuCash 2.4 this report identifier was the report's name. With 2.4 this 
changed to the 
report-guid. We still have some legacy code in our report system to be able to 
read the meta 
files generated in the 2.2 era. So when such an old meta file is encountered 
(for example when 
a user reopens a file now that hasn't been opened since 2.2.x), the reports 
will be properly 
restored.

This compatibility does add an important restriction in our code: report names 
have to be 
unique. Otherwise the wrong report may be restored instead. For standard and 
business reports 
included in GnuCash this is not really an issue. The constraint mostly limits 
the custom reports 
functionality (which I'm currently looking into).

Currently a user is not allowed to save a report without changing the name. 
This is an attempt 
to prevent duplicate report names. But it's already flawed: it's pretty easy to 
change a name 
twice to be able to save the report with an existing name anyway.

Rewriting this to properly prevent duplicate names is probably possible, but 
I'd rather move in 
the other direction: allow duplicate names in custom reports.

My motivations:
- I'm working on the uservoice request to allow to save a custom report without 
requiring to 
change the name first. I have partly rewritten the custom report code with this 
in mind: you can 
now easily rename a custom report directly in the dialog. That would require 
the same duplicate 
name checks and another dialog informing the user in case her name already 
existed.
- Allowing a user to save a report without changing the name under these 
restricting conditions 
is pretty awkward. The best I could come up with is automatically add some 
random suffix to 
the report name upon saving. But this random suffix then also appears on the 
report. This can 
be worked around, but these work-arounds quickly add a lot of complexity. Only 
to preserve 
compatibility with potentially old meta files.
- GnuCash 2.2 is two major releases back when 2.6 is released. We only 
guarantee backwards 
compatibility one major release back.

So I'd like to drop the restriction on duplicate report names. The consequence 
would be we 
can't guarantee anymore that reports stored in old meta files open correctly 
(that is with the 
proper options set). They may, but they may not. So I'd add a warning dialog in 
the code path 
that loads these old meta files, indicating that the report may or may not have 
been loaded 
properly.

Not that this doesn't affect the saved-reports file. It's almost impossible to 
end up in a situation 
where the saved reports are not handled properly due to dropping this 
constraint, because this 
file is versioned. When the code changed to use guids instead of names, the 
file's version was 
bumped. The code to convert from the old to the new format is still in place.

What do you think ?

Geert
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to