r15136 - gnucash/branches/2.0 - Fix auto-completion/pending transactions. #348469.

Derek Atkins warlord at cvs.gnucash.org
Fri Nov 24 13:42:36 EST 2006


Author: warlord
Date: 2006-11-24 13:42:35 -0500 (Fri, 24 Nov 2006)
New Revision: 15136
Trac: http://svn.gnucash.org/trac/changeset/15136

Modified:
   gnucash/branches/2.0/
   gnucash/branches/2.0/ChangeLog
   gnucash/branches/2.0/src/register/ledger-core/split-register-control.c
   gnucash/branches/2.0/src/register/ledger-core/split-register.c
Log:
  Fix auto-completion/pending transactions.  #348469.

	Ensure that the blank transaction is marked as the pending
	transaction when it is modified.  This fixes a bug where editing
	the blank transaction, moving off of the transaction line to a
	split line, leaving the split line unedited and then closing the
	register will incorrectly leave the transaction open without
	asking.  The bug fixed by this commit is possibly responsible for
	some of the crashes like bug #348469.

	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.

Merge r15002 and r15004.




Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
   - 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13613
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
   + 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13614
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282

Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog	2006-11-24 18:42:01 UTC (rev 15135)
+++ gnucash/branches/2.0/ChangeLog	2006-11-24 18:42:35 UTC (rev 15136)
@@ -4,6 +4,32 @@
 	  'gnucash-docs' package when Help is selected with no
 	  content. Fixes #347102.
 
+2006-10-10  Chris Shoemaker <chris.shoemaker at cox.net>
+
+	Ensure that the blank transaction is marked as the pending
+	transaction when it is modified.  This fixes a bug where editing
+	the blank transaction, moving off of the transaction line to a
+	split line, leaving the split line unedited and then closing the
+	register will incorrectly leave the transaction open without
+	asking.  The bug fixed by this commit is possibly responsible for
+	some of the crashes like bug #348469.
+
+	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.
+
 2006-10-09  Andreas Köhler  <andi5.py at gmx.net>
 
 	Lessen restriction of the parameter whoami of the gnc_gconf_add/

Modified: gnucash/branches/2.0/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/branches/2.0/src/register/ledger-core/split-register-control.c	2006-11-24 18:42:01 UTC (rev 15135)
+++ gnucash/branches/2.0/src/register/ledger-core/split-register-control.c	2006-11-24 18:42:35 UTC (rev 15136)
@@ -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;

Modified: gnucash/branches/2.0/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/branches/2.0/src/register/ledger-core/split-register.c	2006-11-24 18:42:01 UTC (rev 15135)
+++ gnucash/branches/2.0/src/register/ledger-core/split-register.c	2006-11-24 18:42:35 UTC (rev 15136)
@@ -1381,8 +1381,11 @@
            g_assert_not_reached();
 
        if (trans == blank_trans) {
-           /* Don't begin editing the blank trans, because it's already open */
+           /* Don't begin editing the blank trans, because it's
+              already open, but mark it pending now. */
            g_assert(xaccTransIsOpen(blank_trans));
+           /* This is now the pending transaction */
+           info->pending_trans_guid = *xaccTransGetGUID(blank_trans);
        } else {
            PINFO("beginning edit of trans %p", trans);
            if (gnc_split_register_begin_edit_or_warn(info, trans))



More information about the gnucash-changes mailing list