After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 746937 - Template transaction splits are loaded in reverse order and then not sorted before saving
Template transaction splits are loaded in reverse order and then not sorted b...
Status: RESOLVED OBSOLETE
Product: GnuCash
Classification: Other
Component: Backend - XML
2.6.4
Other Linux
: Normal minor
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2015-03-28 12:56 UTC by Simon Arlott
Modified: 2018-06-29 23:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against 2.6.4 (442 bytes, patch)
2015-03-28 12:56 UTC, Simon Arlott
rejected Details | Review
Example GnuCash file 1 (14.19 KB, application/xml)
2015-07-23 19:54 UTC, Simon Arlott
  Details
Example GnuCash file 2 (14.19 KB, application/xml)
2015-07-23 19:56 UTC, Simon Arlott
  Details

Description Simon Arlott 2015-03-28 12:56:32 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 1 John Ralls 2015-07-12 18:03:43 UTC
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.
Comment 2 John Ralls 2015-07-12 19:55:25 UTC
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.
Comment 3 Simon Arlott 2015-07-23 19:54:56 UTC
Created attachment 308030 [details]
Example GnuCash file 1
Comment 4 Simon Arlott 2015-07-23 19:56:26 UTC
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
Comment 5 John Ralls 2015-08-03 19:28:19 UTC
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.
Comment 6 John Ralls 2018-06-29 23:39:52 UTC
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.