From 98fe842ae231952718f503e4b6ece39abac0c8ba Mon Sep 17 00:00:00 2001 From: Charles Day Date: Wed, 11 Feb 2009 23:07:51 +0000 Subject: [PATCH] Bug 426111: Register: Fix a bug that caused the blank split GUID to be nulled even if the split wasn't actually being committed. This would cause the bottom transaction of the register to be treated like an existing transaction instead of a new one. I've fixed that and reorganized the logic to combine two sections and make it harder to get them out of sync. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17894 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/ledger-core/split-register.c | 42 +++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c index 6664a0ce0a..d3bf0ecdd0 100644 --- a/src/register/ledger-core/split-register.c +++ b/src/register/ledger-core/split-register.c @@ -1384,7 +1384,6 @@ gnc_split_register_save (SplitRegister *reg, gboolean do_commit) const char *memo; const char *desc; Split *split; - gboolean blank_edited = FALSE; ENTER("reg=%p, do_commit=%s", reg, do_commit ? "TRUE" : "FALSE"); @@ -1428,32 +1427,33 @@ gnc_split_register_save (SplitRegister *reg, gboolean do_commit) return FALSE; } - gnc_suspend_gui_refresh (); + if (trans == pending_trans || + (trans == blank_trans && info->blank_split_edited)) { + /* We are going to commit. */ - if (trans == blank_trans) { - blank_edited = info->blank_split_edited; - info->last_date_entered = xaccTransGetDate (trans); - /* Q: Why should we nullify the blank split GUID if the blank split - * wasn't edited? We still might not be committing! */ - info->blank_split_guid = *guid_null (); - info->blank_split_edited = FALSE; - } + gnc_suspend_gui_refresh (); - /* We have to clear the pending guid *before* committing the - trans, because the event handler will find it otherwise. */ - if (trans == pending_trans) { - info->pending_trans_guid = *guid_null (); - } - - if (trans == pending_trans || blank_edited) { - PINFO("committing trans (%p)", trans); - xaccTransCommitEdit(trans); + if (trans == blank_trans) { + /* We have to clear the blank split before the + * refresh or a new one won't be created. */ + info->last_date_entered = xaccTransGetDate (trans); + info->blank_split_guid = *guid_null (); + info->blank_split_edited = FALSE; + } + + /* We have to clear the pending guid *before* committing the + * trans, because the event handler will find it otherwise. */ + if (trans == pending_trans) + info->pending_trans_guid = *guid_null (); + + PINFO("committing trans (%p)", trans); + xaccTransCommitEdit(trans); + + gnc_resume_gui_refresh (); } else DEBUG("leaving trans (%p) open", trans); - gnc_resume_gui_refresh (); - LEAVE("unchanged cursor"); return TRUE; }