From 48264db7a3e7c01aabea3b8b5a0d94aa4dce4eb4 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 1 Feb 1998 21:35:35 +0000 Subject: [PATCH] fixes to window list utilities git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@482 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/AccWindow.c | 18 ++++++++++++------ src/AdjBWindow.c | 7 ++++--- src/FileIO.c | 10 +++++----- src/MainWindow.c | 5 +++-- src/RecnWindow.c | 8 +++++--- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/AccWindow.c b/src/AccWindow.c index 0568b80a3b..373677f1e2 100644 --- a/src/AccWindow.c +++ b/src/AccWindow.c @@ -557,15 +557,16 @@ editAccWindow( Widget parent, Account *acc ) } /********************************************************************\ + * Don't delete any structures -- the close callback wil do this * \********************************************************************/ void xaccDestroyEditAccWindow (Account * acc) { EditAccWindow *editAccData; - REMOVE_FROM_LIST (EditAccWindow,editAccList,acc,account,editAccData); + FIND_IN_LIST (EditAccWindow,editAccList,acc,account,editAccData); + if (!editAccData) return; XtDestroyWidget (editAccData->dialog); - free (editAccData); } /********************************************************************\ @@ -585,7 +586,7 @@ closeEditAccWindow( Widget mw, XtPointer cd, XtPointer cb ) EditAccWindow *editAccData = (EditAccWindow *)cd; Account *acc = editAccData->account; - REMOVE_FROM_LIST (EditAccWindow,editAccList,acc,account,editAccData); + REMOVE_FROM_LIST (EditAccWindow,editAccList,acc,account); free(editAccData); DEBUG("close EditAccWindow"); } @@ -917,6 +918,7 @@ editNotesWindow (Account *acc) } /********************************************************************\ + * don't delete any structures; te close callack will do this * \********************************************************************/ void @@ -924,10 +926,10 @@ xaccDestroyEditNotesWindow (Account *acc) { EditNotesWindow *edwin; - REMOVE_FROM_LIST (EditNotesWindow,editNotesList,acc,account,edwin) + FIND_IN_LIST (EditNotesWindow,editNotesList,acc,account,edwin) + if (!edwin) return; xaccDestroyTextBox (edwin->tb); - free (edwin); } /********************************************************************\ @@ -937,8 +939,12 @@ static void closeEditNotesWindow( Widget mw, XtPointer cd, XtPointer cb ) { EditNotesWindow *enw = (EditNotesWindow *) cd; + Account * acc = enw->account; - xaccDestroyEditNotesWindow (enw->account); + REMOVE_FROM_LIST (EditNotesWindow,editNotesList,acc,account) + + xaccDestroyTextBox (enw->tb); + free (enw); DEBUG("close EditNotesWindow"); } diff --git a/src/AdjBWindow.c b/src/AdjBWindow.c index e88f3944f4..04aa10666e 100644 --- a/src/AdjBWindow.c +++ b/src/AdjBWindow.c @@ -236,6 +236,7 @@ adjBWindow( Widget parent, Account *acc ) } /********************************************************************\ + * Don't delete any structures, the close callback will do this * \********************************************************************/ void @@ -243,9 +244,9 @@ xaccDestroyAdjBWindow (Account *acc) { AdjBWindow *adjBData; - REMOVE_FROM_LIST (AdjBWindow, adjBList, acc, acc, adjBData); + FIND_IN_LIST (AdjBWindow, adjBList, acc, acc, adjBData); + if (!adjBData) return; XtDestroyWidget (adjBData->dialog); - free (adjBData); } /********************************************************************\ @@ -264,7 +265,7 @@ adjBClose( Widget mw, XtPointer cd, XtPointer cb ) AdjBWindow *adjBData = (AdjBWindow *)cd; Account *acc = adjBData->acc; - REMOVE_FROM_LIST (AdjBWindow, adjBList, acc, acc, adjBData); + REMOVE_FROM_LIST (AdjBWindow, adjBList, acc, acc); free(adjBData); DEBUG("closed AdjBWindow"); diff --git a/src/FileIO.c b/src/FileIO.c index 5e64668a05..9d0aa9a7af 100644 --- a/src/FileIO.c +++ b/src/FileIO.c @@ -247,7 +247,7 @@ xaccReadData( char *datafile ) /* create a lost account, put the missing accounts there */ acc = mallocAccount(); - acc -> accountName = XtNewString (LOST_ACC_STR); + acc -> accountName = strdup (LOST_ACC_STR); acc -> children = (struct _account_group *) holder; insertAccount (grp, acc); } else { @@ -538,7 +538,7 @@ readTransaction( int fd, Account *acc, int token ) return NULL; } xaccTransSetMemo (trans, tmp); - XtFree (tmp); + free (tmp); /* action first introduced in version 3 of the file format */ if (3 <= token) { @@ -759,7 +759,7 @@ readSplit ( int fd, int token ) return NULL; } xaccSplitSetMemo (split, tmp); - XtFree (tmp); + free (tmp); tmp = readString( fd, token ); if( tmp == NULL ) @@ -850,12 +850,12 @@ readString( int fd, int token ) return NULL; XACC_FLIP_INT (size); - str = (char *)XtMalloc(size); + str = (char *) malloc (size); err = read( fd, str, size ); if( err != size ) { printf( "Error: readString: size = %d err = %d str = %s\n", size, err, str ); - XtFree(str); + free(str); return NULL; } diff --git a/src/MainWindow.c b/src/MainWindow.c index d0842ab1cf..d7a6084c7b 100644 --- a/src/MainWindow.c +++ b/src/MainWindow.c @@ -155,10 +155,11 @@ xaccDestroyMainArrow (Account *acc ) { MainArrow *arrowData; - REMOVE_FROM_LIST (MainArrow, arrowList, acc, account, arrowData); - + FIND_IN_LIST (MainArrow, arrowList, acc, account, arrowData); if (!arrowData) return; + REMOVE_FROM_LIST (MainArrow, arrowList, acc, account); + XtRemoveCallback (arrowData->arrowb, XmNactivateCallback, expandListCB, (XtPointer *) arrowData); diff --git a/src/RecnWindow.c b/src/RecnWindow.c index c490d2e5fa..2934738dcc 100644 --- a/src/RecnWindow.c +++ b/src/RecnWindow.c @@ -87,6 +87,7 @@ recnRefresh (Account *acc) RecnWindow *recnData; FIND_IN_LIST (RecnWindow, recnList, acc, acc, recnData); + if (!recnData) return; /* NOTE: an improvement of the current design would be to use the * user-data in the rows to detect where transactions need @@ -758,6 +759,7 @@ recnWindow( Widget parent, Account *acc ) } /********************************************************************\ + * Don't delete any structures -- the close callback will handle this * \********************************************************************/ void @@ -765,9 +767,9 @@ xaccDestroyRecnWindow (Account *acc) { RecnWindow *recnData; - REMOVE_FROM_LIST (RecnWindow, recnList, acc, acc, recnData); + FIND_IN_LIST (RecnWindow, recnList, acc, acc, recnData); + if (!recnData) return; XtDestroyWidget (recnData->dialog); - free (recnData); } /********************************************************************\ @@ -786,7 +788,7 @@ recnClose( Widget mw, XtPointer cd, XtPointer cb ) RecnWindow *recnData = (RecnWindow *)cd; Account *acc = recnData->acc; - REMOVE_FROM_LIST (RecnWindow, recnList, acc, acc, recnData); + REMOVE_FROM_LIST (RecnWindow, recnList, acc, acc); free(recnData); DEBUG("closed RecnWindow");