[Gnucash-changes] r13343 - gnucash/trunk - A different approach to
ensuring that a (unique) relevent split from the
currently-pending transaction is always in the split list
before we load it.
Joshua Sled
jsled at cvs.gnucash.org
Tue Feb 21 13:40:33 EST 2006
Author: jsled
Date: 2006-02-21 13:40:32 -0500 (Tue, 21 Feb 2006)
New Revision: 13343
Trac: http://svn.gnucash.org/trac/changeset/13343
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/register/ledger-core/split-register-load.c
gnucash/trunk/src/register/ledger-core/split-register-p.h
gnucash/trunk/src/register/ledger-core/split-register.c
Log:
A different approach to ensuring that a (unique) relevent split from the currently-pending transaction is always in the split list before we load it.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-21 15:42:19 UTC (rev 13342)
+++ gnucash/trunk/ChangeLog 2006-02-21 18:40:32 UTC (rev 13343)
@@ -1,5 +1,17 @@
2006-02-21 Joshua Sled <jsled at asynchronous.org>
+ * 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 <hampton at employees.org>
+
+ * 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 <derek at ihtfp.com>
* src/engine/Transaction.c:
Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c 2006-02-21 15:42:19 UTC (rev 13342)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c 2006-02-21 18:40:32 UTC (rev 13343)
@@ -129,6 +129,14 @@
}
+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 @@
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 @@
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 @@
/* enable callback for cursor user-driven moves */
gnc_table_control_allow_move (table->control, TRUE);
+
+ if (we_own_slist)
+ g_list_free(slist);
}
/* ===================================================================== */
Modified: gnucash/trunk/src/register/ledger-core/split-register-p.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-p.h 2006-02-21 15:42:19 UTC (rev 13342)
+++ gnucash/trunk/src/register/ledger-core/split-register-p.h 2006-02-21 18:40:32 UTC (rev 13343)
@@ -109,8 +109,6 @@
char *credit_str;
char *tdebit_str;
char *tcredit_str;
-
- GList *saved_slist;
};
Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c 2006-02-21 15:42:19 UTC (rev 13342)
+++ gnucash/trunk/src/register/ledger-core/split-register.c 2006-02-21 18:40:32 UTC (rev 13343)
@@ -2356,13 +2356,11 @@
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);
More information about the gnucash-changes
mailing list