GNOME Bugzilla – Bug 746937
Template transaction splits are loaded in reverse order and then not sorted before saving
Last modified: 2018-06-29 23:39:52 UTC
Created attachment 300514 [details] [review] Patch against 2.6.4 Template transaction splits are loaded in reverse order and then not sorted because the sort_dirty states of template accounts are only checked when the scheduled transaction editor is opened (via gnc_tree_model_account_get_value). If there are two or more transactions for a template account then this causes them to get written in a different order every time the file is loaded and saved. This causes spurious changes to be detected when tracking changes to the XML file. Before writing out the transactions for an account, xaccAccountSortSplits() should be called to ensure that the splits are sorted.
Comment on attachment 300514 [details] [review] Patch against 2.6.4 I imagine you focused on the call to xaccAccountTreeForEachTransaction() in write_template_transaction_data() in io-gncxml-v2.c. Unfortunately it's also used for writing out (more than once) and reading the whole book, both of which are already pretty slow. That aside, it takes a const Account*, so mutating the account inside the call isn't allowed.
Not only that, I can't replicate the problem with on Debian or OSX. diffing a file and its backup doesn't show any changes in the gnc:template-transactions section of the file. Perhaps my test file doesn't have a sufficient number of SXes to trigger it; please attach a test file that demonstrates the problem.
Created attachment 308030 [details] Example GnuCash file 1
Created attachment 308031 [details] Example GnuCash file 2 Tested with GnuCash 2.6.7: 1. Open example file 1 2. Save the file 3. The output file contains the same content as example file 2 4. Open example file 2 5. Save the file 6. The output file contains the same content as example file 1
Got it. I still don't know if we can fix this without bogging down program write and load, but I'll look into it.
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=746937. Please continue processing the bug there and please update any external references or bookmarks.