gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Jul 28 17:24:48 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/dee01706 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/cbe765c6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/5ac8ffdd (commit)



commit dee01706eb5e34f04e02a54940bffd89b2ce1bd3
Merge: 5ac8ffdd41 cbe765c6d9
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Jul 28 12:10:22 2023 -0700

    Merge John Ralls's 'bug798958' into stable.


commit cbe765c6d95fe22beff4088faa6e21948cd3b5f0
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jul 20 18:18:39 2023 -0700

    Bug 798958 - gncScrubLotLinks will infinite loop in some conditions
    
    The conditions being containing a split from a voided transaction.
    Instead of trying to destroy zero-value splits (doomed to fail in
    that instance and generally rude otherwise) just remove them from
    the lot list.

diff --git a/libgnucash/engine/ScrubBusiness.c b/libgnucash/engine/ScrubBusiness.c
index 367becd9b2..0a68fc9531 100644
--- a/libgnucash/engine/ScrubBusiness.c
+++ b/libgnucash/engine/ScrubBusiness.c
@@ -214,13 +214,21 @@ scrub_start:
         if (xaccTransGetTxnType (ll_txn) == TXN_TYPE_INVOICE)
             continue; // next scrub lot split
 
-        // Empty splits can be removed immediately
-        if (gnc_numeric_zero_p (xaccSplitGetValue (sl_split)) ||
-                gnc_numeric_zero_p(xaccSplitGetValue (sl_split)))
+        // Empty splits can be immediately removed from the list.
+        if (gnc_numeric_zero_p (xaccSplitGetValue (sl_split)))
         {
-            xaccSplitDestroy (sl_split);
-            modified = TRUE;
-            goto scrub_start;
+            GList *tmp_iter = sls_iter->prev;
+            PINFO("Removing 0-value split from the lot.");
+
+            if (xaccTransGetReadOnly(xaccSplitGetParent(sl_split)))
+                gnc_lot_remove_split (scrub_lot, sl_split);
+            else
+                xaccSplitDestroy (sl_split);
+
+            sls_iter = tmp_iter;
+            if (!sls_iter)
+                goto scrub_start; // Otherwise sls_iter->next will crash
+            continue;
         }
 
         // Iterate over all splits in the lot link transaction



Summary of changes:
 libgnucash/engine/ScrubBusiness.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list