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
This commit is contained in:
Charles Day 2009-02-11 23:07:51 +00:00
parent 1ea8e0f8bf
commit 98fe842ae2

View File

@ -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;
}