From 84d60699dbe801b71e5692461172b8c7b277a871 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 1 Apr 1998 05:01:10 +0000 Subject: [PATCH] fix multiple bugs relating to transfers git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@765 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/Ledger.c | 3 ++- src/engine/Account.c | 16 +++++++++++++++- src/register/combocell.c | 1 + src/register/table-allgui.c | 20 ++++++++++++-------- src/register/table-motif.c | 6 ++++-- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/Ledger.c b/src/Ledger.c index 9ee080caa9..aaf6812997 100644 --- a/src/Ledger.c +++ b/src/Ledger.c @@ -174,8 +174,9 @@ xaccSaveRegEntry (BasicRegister *reg) if (MOD_ACTN & changed) xaccSplitSetAction (split, reg->actionCell->cell.value); - if (MOD_XFRM & changed) + if (MOD_XFRM & changed) { xaccMoveFarEndByName (split, reg->xfrmCell->cell.value); + } if (MOD_XTO & changed) { /* hack alert -- implement this */ diff --git a/src/engine/Account.c b/src/engine/Account.c index 701addbd70..e76a436ba0 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -573,6 +573,7 @@ xaccMoveFarEnd (Split *split, Account *new_acc) Split *partner_split = 0x0; Transaction *trans; Account * acc; + int create_far_end = 0; if (!split) return; @@ -589,10 +590,24 @@ xaccMoveFarEnd (Split *split, Account *new_acc) if (0x0 == trans->dest_splits[1]) { partner_split = trans->dest_splits[0]; } + } else { + /* Gosh, the far end doesn't exist! create it! */ + create_far_end = 1; } + } else { + /* Gosh, the far end doesn't exist! create it! */ + create_far_end = 1; } } + /* Gosh, the far end doesn't exist! create it! */ + if (create_far_end && new_acc) { + partner_split = xaccMallocSplit (); + xaccTransAppendSplit (trans, partner_split); + xaccAccountInsertSplit (new_acc, partner_split); + return; + } + if (partner_split) { /* remove the partner split from the old account */ acc = (Account *) (partner_split->acc); @@ -616,7 +631,6 @@ xaccMoveFarEndByName (Split *split, const char *new_acc_name) acc = (Account *) split->acc; acc = xaccGetPeerAccountFromName (acc, new_acc_name); - xaccMoveFarEnd (split, acc); } diff --git a/src/register/combocell.c b/src/register/combocell.c index 37a1904ab3..34e811aa29 100644 --- a/src/register/combocell.c +++ b/src/register/combocell.c @@ -59,6 +59,7 @@ static const char * leaveCombo (BasicCell *bcell, const char *value); #define SET(cell,str) { \ if ((cell)->value) free ((cell)->value); \ (cell)->value = strdup (str); \ + (cell)->changed = 0xffffffff; \ } /* =============================================== */ diff --git a/src/register/table-allgui.c b/src/register/table-allgui.c index 276aab5404..554d06a485 100644 --- a/src/register/table-allgui.c +++ b/src/register/table-allgui.c @@ -36,7 +36,7 @@ * template. This one will resize a 2D array. */ -#define RESIZE_ARR(table_rows,table_cols,new_rows,new_cols,arr,type,null_val) \ +#define RESIZE_ARR(table_rows,table_cols,new_rows,new_cols,arr,type,null_val,do_free_cell_contents) \ { \ int old_rows, old_cols; \ int i,j; \ @@ -56,7 +56,7 @@ /* simply truncate columns */ \ for (i=0; ientries), char, - (strdup (""))); + (strdup ("")), + 1); /* resize the locator array */ RESIZE_ARR ((table->num_phys_rows), @@ -215,7 +216,8 @@ xaccTableResize (Table * table, new_phys_cols, (table->locators), Locator, - (xaccMallocLocator ())); + (xaccMallocLocator ()), + 1); /* we are done with the physical dimensions. * record them for posterity. */ @@ -230,7 +232,8 @@ xaccTableResize (Table * table, new_virt_cols, (table->user_data), void, - (NULL)); + (NULL), + 0); /* resize the handler array */ RESIZE_ARR ((table->num_virt_rows), @@ -239,7 +242,8 @@ xaccTableResize (Table * table, new_virt_cols, (table->handlers), CellBlock, - (NULL)); + (NULL), + 0); /* we are done with the virtual dimensions. * record them for posterity. */ diff --git a/src/register/table-motif.c b/src/register/table-motif.c index 975b46ec06..fadf76e3da 100644 --- a/src/register/table-motif.c +++ b/src/register/table-motif.c @@ -385,6 +385,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb) /* update data. bounds check done earlier */ free (table->entries[row][col]); table->entries[row][col] = newval; + (arr->cells[rel_row][rel_col])->changed = 0xffffffff; } } @@ -632,9 +633,10 @@ void xaccRefreshTableGUI (Table * table) { {int i; -printf (" refresh %d %d \n", table->num_phys_rows,table->num_phys_cols); +printf (" refresh numphysrows=%d numphyscols=%d \n", table->num_phys_rows,table->num_phys_cols); for (i=0; inum_phys_rows; i++) { -printf ("cell %d descr: %s \n", i, table->entries[i][3]); +printf ("cell %d act:%s descr: %s \n", i, table->entries[i][2], +table->entries[i][3]); }} XtVaSetValues (table->table_widget, XmNrows, table->num_phys_rows, XmNcolumns, table->num_phys_cols,