From e884d61a54f2f44efcc45d9589020c48180fb9fc Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 3 Feb 1999 07:59:15 +0000 Subject: [PATCH] fix a silly core dump when destroying accounts with open windows git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1667 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/MultiLedger.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/MultiLedger.c b/src/MultiLedger.c index 2be81d46af..8500ee5c59 100644 --- a/src/MultiLedger.c +++ b/src/MultiLedger.c @@ -574,19 +574,23 @@ xaccDestroyLedgerDisplay (Account *acc) xaccLedgerDisplay *regData; int n; + if (!acc) return; + /* find the single-account window for this account, if any */ FIND_IN_LIST (xaccLedgerDisplay, regList, acc, leader, regData); if (regData) { if (regData->destroy) { (regData->destroy) (regData); } + xaccLedgerDisplayClose (regData); } /* find the multiple-account window for this account, if any */ FIND_IN_LIST (xaccLedgerDisplay, ledgerList, acc, leader, regData); if (regData) { if (regData->destroy) { (regData->destroy) (regData); } + xaccLedgerDisplayClose (regData); } - /* cruise throught the miscellanous account windows */ + /* cruise throught the miscellaneous account windows */ if (!fullList) return; n = 0; regData = fullList[n]; @@ -596,6 +600,8 @@ xaccDestroyLedgerDisplay (Account *acc) got_one = ledgerIsMember (regData, acc); if (got_one) { if (regData->destroy) { (regData->destroy) (regData); } + xaccLedgerDisplayClose (regData); + n = -1; /* since the above alters this list */ } n++; regData = fullList[n]; @@ -615,8 +621,11 @@ xaccDestroyLedgerDisplay (Account *acc) void xaccLedgerDisplayClose (xaccLedgerDisplay *regData) { - Account *acc = regData->leader; + Account *acc; + if (!regData) return; + acc = regData->leader; + /* Save any unsaved changes */ xaccSRSaveRegEntry (regData->ledger);