misc bug & core dump fixes

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@485 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas
1998-02-02 01:17:38 +00:00
parent f86a6520b4
commit 8348efbfad
5 changed files with 45 additions and 32 deletions

View File

@@ -322,7 +322,7 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
xaccSetAmount (&(trans->credit_split), dcurrAmount - themount);
/* Refresh the account register window */
regRefresh(acc);
accRefresh(acc);
/* Refresh the account reconcile window */
recnRefresh (acc);

View File

@@ -7,6 +7,7 @@
*/
#include "Ledger.h"
#include "messages.h"
#include "register.h"
#include "Transaction.h"
@@ -63,20 +64,27 @@ xaccSaveRegEntry (BasicRegister *reg)
/* ======================================================== */
static Account *
GetPeerAcc (Split *split)
static char *
GetPeerAccName (Split *split)
{
Account *acc;
Account *acc = NULL;
Transaction *trans;
trans = (Transaction *) (split->parent);
/* hack alert -- this is incorrect for splits in general */
if (split != &(trans->credit_split)) {
acc = (Account *) trans->credit_split.acc;
} else {
acc = (Account *) trans->debit_splits[0]->acc;
if (trans->debit_splits) {
/* if only one split, then use that */
if (NULL == trans->debit_splits[1]) {
acc = (Account *) trans->debit_splits[0]->acc;
} else {
return SPLIT_STR;
}
}
}
return acc;
if (acc) return acc->accountName;
return "";
}
/* ======================================================== */
@@ -85,7 +93,7 @@ void
xaccLoadRegEntry (BasicRegister *reg, Split *split)
{
Transaction *trans;
Account *acc;
char *accname;
char buff[2];
if (!split) return;
@@ -105,8 +113,9 @@ xaccLoadRegEntry (BasicRegister *reg, Split *split)
xaccSetBasicCellValue (reg->recnCell, buff);
/* the transfer account */
acc = GetPeerAcc (split);
xaccSetBasicCellValue (&(reg->xfrmCell->cell), acc->accountName);
/* hack alert -- this is incorrect for splits in general */
accname = GetPeerAccName (split);
xaccSetBasicCellValue (&(reg->xfrmCell->cell), accname);
xaccSetDebCredCellValue (reg->debitCell,
reg->creditCell, split->damount);

View File

@@ -147,6 +147,8 @@ recnRefresh (Account *acc)
XbaeMatrixSetRowUserData( recnData->credit,nrows, (XtPointer)split );
}
}
i++;
split = acc->splits[i];
}
recnRecalculateBalance(recnData);
@@ -841,7 +843,7 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
}
/* refresh the register window */
regRefresh(recnData->acc);
accRefresh(recnData->acc);
}
/********************************************************************\

View File

@@ -90,7 +90,7 @@ static RegWindow **fullList = NULL; /* all registers */
/** PROTOTYPES ******************************************************/
RegWindow * regWindowLedger( Widget parent, Account *lead, Account **acclist, int type);
void regRefresh (Account *acc);
void accRefresh (Account *acc);
static void closeRegWindow( Widget mw, XtPointer cd, XtPointer cb );
static void startRecnCB( Widget mw, XtPointer cd, XtPointer cb );
@@ -466,7 +466,7 @@ regWindowLedger( Widget parent, Account *lead_acc, Account **acclist, int ledger
activityMenu[4].subitems = reportMenu;
/* can't adjust the balance on a ledger window */
if (1 != regData->numAcc) {
if (1 < regData->numAcc) {
activityMenu[2].sensitive = False;
activityMenu[3].sensitive = False;
}
@@ -632,8 +632,7 @@ regWindowLedger( Widget parent, Account *lead_acc, Account **acclist, int ledger
/******************************************************************/
XtManageChild(pane);
/* hack alert -- if no leader, should be refreshing from list */
regRefresh (regData->leader);
accRefresh (regData->leader);
XtPopup( regData->dialog, XtGrabNone );
@@ -642,11 +641,21 @@ regWindowLedger( Widget parent, Account *lead_acc, Account **acclist, int ledger
return regData;
}
/********************************************************************\
* refresh only the indicated register window *
\********************************************************************/
void regRefresh (RegWindow *regData)
{
/* hack alert -- should be recomputing the list of splits */
xaccLoadRegister (regData->ledger, regData->leader->splits);
}
/********************************************************************\
* refresh *all* register windows which contain this account *
\********************************************************************/
void regRefresh (Account *acc)
void accRefresh (Account *acc)
{
RegWindow *regData;
int n;
@@ -665,7 +674,7 @@ void regRefresh (Account *acc)
if (got_one) {
/* hack alert -- should be recomputing the list of splits */
/* and problbly the balance too */
xaccLoadRegister (regData->ledger, acc->splits);
regRefresh (regData);
}
n++;
regData = fullList[n];

View File

@@ -476,23 +476,16 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
xaccTransSetReconcile (trans, NREC);
/* make note of which accounts this was transfered from & to */
split->acc = (struct _account *) getAccount(grp,xferData->from);
trans->credit_split.acc = (struct _account *) getAccount(grp,xferData->to);
/* insert transaction into from acount */
xaccInsertSplit (((Account *) (split->acc)), split);
/* Refresh the "from" account register window */
regRefresh(acc);
/* Refresh the "from" account reconcile window */
acc = getAccount(grp,xferData->from);
split->acc = (struct _account *) acc;
xaccInsertSplit (acc, split);
accRefresh(acc);
recnRefresh(acc);
/* insert transaction into to acount */
xaccInsertSplit (((Account *) (trans->credit_split.acc)), &(trans->credit_split));
/* Refresh the "to" account register window */
regRefresh(acc);
/* Refresh the "to" account reconcile window */
acc = getAccount(grp,xferData->to);
trans->credit_split.acc = (struct _account *) acc;
xaccInsertSplit (acc, &(trans->credit_split));
accRefresh(acc);
recnRefresh(acc);
refreshMainWindow();