AUDIT: r15004 - gnucash/trunk/src/register/ledger-core - This fixes a bug in r14495. The bug is that auto-completed transactions

Chris Shoemaker chris at cvs.gnucash.org
Tue Oct 10 20:57:53 EDT 2006


Author: chris
Date: 2006-10-10 20:57:52 -0400 (Tue, 10 Oct 2006)
New Revision: 15004
Trac: http://svn.gnucash.org/trac/changeset/15004

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-control.c
Log:
This fixes a bug in r14495.  The bug is that auto-completed transactions 
aren't correctly marked as pending.  This bug is probably responsible for
the crashes like those in bug #348469.

In general, the register makes it very difficult to consistently 
distiguish between beginning to edit a transaction that's being edited 
in another register and beginning to edit the blank transaction, 
which is already open for editing, but isn't marked pending so that
we can pretend it hasn't been opened if it never gets modified.

Fortunately, the auto-completion code only runs on the blank transaction, 
so we can assume it's not being edited in another register.  This patch
goes ahead and marks the blank transaction as pending.
BP



Modified: gnucash/trunk/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-control.c	2006-10-11 00:44:31 UTC (rev 15003)
+++ gnucash/trunk/src/register/ledger-core/split-register-control.c	2006-10-11 00:57:52 UTC (rev 15004)
@@ -676,20 +676,25 @@
 
 	gnc_suspend_gui_refresh ();
 
+        /* We are guaranteed to be on the blank trans, so we can
+           discount the possibility that the current transaction is
+           being edited in another register. */
         /* now perform the completion */
-        if ((pending_trans != NULL) && (pending_trans != trans)) {
-            if (gnc_split_register_begin_edit_or_warn(info, trans))
-	    {
-	        gnc_resume_gui_refresh ();
-                return TRUE;
-	    }
-
-            if (xaccTransIsOpen (pending_trans))
-                xaccTransCommitEdit (pending_trans);
-            else g_assert_not_reached();
+        if (pending_trans != trans) {
+            if (!xaccTransIsOpen(trans))
+                xaccTransBeginEdit(trans);
+            /* This is now the pending transaction */
+            info->pending_trans_guid = *xaccTransGetGUID(trans);
+            if (pending_trans != NULL) {
+                if (xaccTransIsOpen (pending_trans))
+                    xaccTransCommitEdit (pending_trans);
+                else g_assert_not_reached();
+            }
         }
         g_assert(xaccTransIsOpen(trans));
-        pending_trans = trans;
+        pending_trans = xaccTransLookup(&info->pending_trans_guid,
+                                        gnc_get_current_book ());
+        g_assert(pending_trans == trans);
 
         gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE);
         blank_split = NULL;



More information about the gnucash-changes mailing list