diff --git a/ChangeLog b/ChangeLog index c77f2fa072..a29439c577 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2006-02-21 Joshua Sled + * src/register/ledger-core/split-register-load.c + (gnc_split_register_load): Ensure that a (unique) relevent split + from the currently-pending transaction is always in the split list + before we load it, preventing transactions from disappearing from + a register while being edited, but without saving the entire (and + maybe partially-invalid) split list around for a while. Fixes bugs + 108347, 125480, 141287, 153183, 168630 (and maybe 126471). + + * src/register/ledger-core/split-register.c (gnc_split_register_destroy_info): + * src/register/ledger-core/split-register-p.h (struct sr_info): + Remove saved_slist. + * lib/libqof/qof/qofevent.h (QOF_EVENT_CREATE): Fix event values. @@ -77,6 +89,12 @@ "visible to the user" lines in the register has shrunk, force the parent widget to redraw. This fixes #328787. +2006-02-20 David Hampton + + * src/register/register-gnome/gnucash-sheet.c: If the number of + "visible to the user" lines in the register has shrunk, force the + parent widget to redraw. This fixes #328787. + 2006-02-19 Derek Atkins * src/engine/Transaction.c: diff --git a/src/register/ledger-core/split-register-load.c b/src/register/ledger-core/split-register-load.c index f26c9dc0da..6e8c1b77e2 100644 --- a/src/register/ledger-core/split-register-load.c +++ b/src/register/ledger-core/split-register-load.c @@ -129,6 +129,14 @@ gnc_split_register_add_transaction (SplitRegister *reg, } +static gint +_find_split_with_parent_txn(gconstpointer a, gconstpointer b) +{ + Split *split = (Split*)a; + Transaction *txn = (Transaction*)b; + return xaccSplitGetParent(split) == txn ? 0 : 1; +} + void gnc_split_register_load (SplitRegister *reg, GList * slist, Account *default_account) @@ -157,6 +165,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist, gboolean has_last_num = FALSE; gboolean multi_line; gboolean dynamic; + gboolean we_own_slist = FALSE; VirtualCellLocation vcell_loc; VirtualLocation save_loc; @@ -323,19 +332,29 @@ gnc_split_register_load (SplitRegister *reg, GList * slist, if (multi_line) trans_table = g_hash_table_new (g_direct_hash, g_direct_equal); - /* - * Which split list to use? If there is a transction pending, then - * use the saved list so that the transaction is guaranteed to - * remain in the register intil the user finishes editing - * it. Otherwise, the moment the user changes the account field of - * the split that is attached to the register, the transaction will - * be ripped out from underneath them. - */ - if (pending_trans != NULL) { - slist = info->saved_slist; - } else { - g_list_free(info->saved_slist); - info->saved_slist = g_list_copy(slist); + // Ensure that the transaction and splits being edited are in the split + // list we're about to load. + if (pending_trans != NULL) + { + SplitList *splits; + for (splits = xaccTransGetSplitList(pending_trans); splits; splits = splits->next) + { + Split *pending_split = (Split*)splits->data; + if (g_list_find(slist, pending_split) != NULL) + continue; + + //printf("pending_split [%s] not found\n", guid_to_string(xaccSplitGetGUID(pending_split))); + if (g_list_find_custom(slist, pending_trans, _find_split_with_parent_txn) != NULL) + continue; + + //printf("transaction [%s] not found\n", guid_to_string(xaccTransGetGUID(pending_trans))); + if (!we_own_slist) + { // lazy-copy + slist = g_list_copy(slist); + we_own_slist = TRUE; + } + slist = g_list_append(slist, pending_split); + } } /* populate the table */ @@ -538,6 +557,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist, /* enable callback for cursor user-driven moves */ gnc_table_control_allow_move (table->control, TRUE); + + if (we_own_slist) + g_list_free(slist); } /* ===================================================================== */ diff --git a/src/register/ledger-core/split-register-p.h b/src/register/ledger-core/split-register-p.h index 345a5a79f1..6092aacf53 100644 --- a/src/register/ledger-core/split-register-p.h +++ b/src/register/ledger-core/split-register-p.h @@ -109,8 +109,6 @@ struct sr_info char *credit_str; char *tdebit_str; char *tcredit_str; - - GList *saved_slist; }; diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c index 8233572ac7..61e70e2f2e 100644 --- a/src/register/ledger-core/split-register.c +++ b/src/register/ledger-core/split-register.c @@ -2356,13 +2356,11 @@ gnc_split_register_destroy_info (SplitRegister *reg) g_free (info->tdebit_str); g_free (info->credit_str); g_free (info->tcredit_str); - g_list_free (info->saved_slist); info->debit_str = NULL; info->tdebit_str = NULL; info->credit_str = NULL; info->tcredit_str = NULL; - info->saved_slist = NULL; g_free (reg->sr_info);