[Gnucash-changes] r13883 - gnucash/trunk/src/register/ledger-core - When deleting the current Transaction in the register, let the action take

Chris Shoemaker chris at cvs.gnucash.org
Sat Apr 29 20:43:45 EDT 2006


Author: chris
Date: 2006-04-29 20:43:45 -0400 (Sat, 29 Apr 2006)
New Revision: 13883
Trac: http://svn.gnucash.org/trac/changeset/13883

Modified:
   gnucash/trunk/src/register/ledger-core/split-register.c
Log:
   When deleting the current Transaction in the register, let the action take
   effect immediately by commiting the transaction if it's open.


Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c	2006-04-29 22:42:33 UTC (rev 13882)
+++ gnucash/trunk/src/register/ledger-core/split-register.c	2006-04-30 00:43:45 UTC (rev 13883)
@@ -849,6 +849,7 @@
   Transaction *trans;
   Split *blank_split;
   Split *split;
+  gboolean was_open;
 
   if (!reg) return;
 
@@ -862,50 +863,28 @@
   if (split == NULL)
     return;
 
+  gnc_suspend_gui_refresh ();
+  trans = xaccSplitGetParent(split);
+
   /* If we just deleted the blank split, clean up. The user is
    * allowed to delete the blank split as a method for discarding
    * any edits they may have made to it. */
-  if (split == blank_split)
-  {
-    trans = xaccSplitGetParent (blank_split);
-
-    /* Make sure we don't commit this later on */
-    if (trans == pending_trans)
-    {
+  if (split == blank_split) {
+      info->blank_split_guid = *guid_null();
+  } else {
+      info->trans_expanded = FALSE;      
+  }
+  
+  /* Check pending transaction */
+  if (trans == pending_trans) {
       info->pending_trans_guid = *guid_null();
       pending_trans = NULL;
-    }
-
-    gnc_suspend_gui_refresh ();
-
-    xaccTransDestroy (trans);
-
-    info->blank_split_guid = *guid_null();
-    blank_split = NULL;
-
-    gnc_resume_gui_refresh ();
-
-    return;
   }
 
-  info->trans_expanded = FALSE;
-
-  gnc_suspend_gui_refresh ();
-
-  /* make a copy of all of the accounts that will be  
-   * affected by this deletion, so that we can update
-   * their register windows after the deletion. */
-  trans = xaccSplitGetParent(split);
-
+  was_open = xaccTransIsOpen(trans);
   xaccTransDestroy(trans);
-
-  /* Check pending transaction */
-  if (trans == pending_trans)
-  {
-    info->pending_trans_guid = *guid_null();
-    pending_trans = NULL;
-  }
-
+  if (was_open)
+      xaccTransCommitEdit(trans);
   gnc_resume_gui_refresh ();
 }
 



More information about the gnucash-changes mailing list