From e3bef5fdc3abddb2cb6c6913e6a2f43375db0ef4 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 17 Dec 2014 18:51:39 +0100 Subject: [PATCH] Fix lot scrubbing for business lots When adding splits to such a lot the code was supposed to reduce splits in the same transaction and the same lot to one single split. This is to avoid infinite fragmentation over time. That reduction wasn't working for business lots and should be fixed with this commit. This is also a potential fix for bug https://bugzilla.gnome.org/show_bug.cgi?id=741418 which could very well be a report of such infinite fragmentation. --- src/engine/Scrub2.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/engine/Scrub2.c b/src/engine/Scrub2.c index 4c9b6a7633..10ee3f89ec 100644 --- a/src/engine/Scrub2.c +++ b/src/engine/Scrub2.c @@ -366,18 +366,21 @@ restart: if (s == split) continue; if (qof_instance_get_destroying(s)) continue; - /* OK, this split is in the same lot (and thus same account) - * as the indicated split. Make sure it is really a subsplit - * of the split we started with. It's possible to have two - * splits in the same lot and transaction that are not subsplits - * of each other, the test-period test suite does this, for - * example. Only worry about adjacent sub-splits. By - * repeatedly merging adjacent subsplits, we'll get the non- - * adjacent ones too. */ - guid = qof_instance_get_guid(s); - if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split", - "peer_guid", guid) == NULL) - continue; + if (strict) + { + /* OK, this split is in the same lot (and thus same account) + * as the indicated split. Make sure it is really a subsplit + * of the split we started with. It's possible to have two + * splits in the same lot and transaction that are not subsplits + * of each other, the test-period test suite does this, for + * example. Only worry about adjacent sub-splits. By + * repeatedly merging adjacent subsplits, we'll get the non- + * adjacent ones too. */ + guid = qof_instance_get_guid(s); + if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split", + "peer_guid", guid) == NULL) + continue; + } merge_splits (split, s); rc = TRUE;