fix multiple bugs relating to transfers

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@765 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-04-01 05:01:10 +00:00
parent 90bbe9e6f9
commit 84d60699db
5 changed files with 34 additions and 12 deletions

View File

@ -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 */

View File

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

View File

@ -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; \
}
/* =============================================== */

View File

@ -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; i<new_rows; i++) { \
for (j=new_cols; j<old_cols; j++) { \
free (arr[i][j]); \
if (do_free_cell_contents) free (arr[i][j]); \
arr[i][j] = NULL; \
} \
} \
@ -82,7 +82,7 @@
/* new table has fewer rows. Simply truncate the rows */ \
for (i=new_rows; i<old_rows; i++) { \
for (j=0; j<old_cols; j++) { \
free (arr[i][j]); \
if (do_free_cell_contents) free (arr[i][j]); \
} \
free (arr[i]); \
arr[i] = NULL; \
@ -98,7 +98,7 @@
/* Simply truncate the columns */ \
for (i=0; i<old_rows; i++) { \
for (j=new_cols; j<old_cols; j++) { \
free (arr[i][j]); \
if (do_free_cell_contents) free (arr[i][j]); \
arr[i][j] = NULL; \
} \
} \
@ -206,7 +206,8 @@ xaccTableResize (Table * table,
new_phys_cols,
(table->entries),
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. */

View File

@ -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; i<table->num_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,