From 796462c9fc6331cbdf08cbb8f99bf822eadd6abb Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Thu, 22 Oct 1998 02:21:21 +0000 Subject: [PATCH] More memory leak fixes --- calendar/modules/core/src/nsCalendarModel.cpp | 4 +++- calendar/modules/core/src/nsLayerCollection.cpp | 10 ++++++++++ calendar/modules/shell/src/nsCalendarContainer.cpp | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/calendar/modules/core/src/nsCalendarModel.cpp b/calendar/modules/core/src/nsCalendarModel.cpp index 2e560e7f19d..229b0c0c7d8 100644 --- a/calendar/modules/core/src/nsCalendarModel.cpp +++ b/calendar/modules/core/src/nsCalendarModel.cpp @@ -97,6 +97,8 @@ NS_IMPL_RELEASE(nsCalendarModel) nsCalendarModel::~nsCalendarModel() { +// XXX +#if 0 nsIXPFCObserverManager* om; nsServiceManager::GetService(kCXPFCObserverManagerCID, kIXPFCObserverManagerIID, (nsISupports**)&om); @@ -104,7 +106,7 @@ nsCalendarModel::~nsCalendarModel() nsresult res = om->Unregister((nsISupports *)(void*)this); nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om); - +#endif mCalendarUser = nsnull; // Do Not Release } diff --git a/calendar/modules/core/src/nsLayerCollection.cpp b/calendar/modules/core/src/nsLayerCollection.cpp index 28392838e67..72606eb97c3 100644 --- a/calendar/modules/core/src/nsLayerCollection.cpp +++ b/calendar/modules/core/src/nsLayerCollection.cpp @@ -75,6 +75,15 @@ NS_IMPL_RELEASE(nsLayerCollection) nsLayerCollection::~nsLayerCollection() { // XXX: Need to add a way to remove ref when delete all! + nsILayer * pLayer; + + while (mLayers->Count() > 0 ) + { + pLayer = (nsILayer*)mLayers->ElementAt(0); + RemoveLayer(pLayer); + mLayers->RemoveAt(0); + } + NS_IF_RELEASE(mLayers); } @@ -198,6 +207,7 @@ nsresult nsLayerCollection::SetCurl(const JulianString& sC) pLayer->Init(); pLayer->SetCurl(s); AddLayer(pLayer); + NS_RELEASE(pLayer); } return (NS_OK); } diff --git a/calendar/modules/shell/src/nsCalendarContainer.cpp b/calendar/modules/shell/src/nsCalendarContainer.cpp index c88064d3d14..b706b78036e 100644 --- a/calendar/modules/shell/src/nsCalendarContainer.cpp +++ b/calendar/modules/shell/src/nsCalendarContainer.cpp @@ -213,6 +213,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent, //mRootCanvas->SetVisibility(PR_FALSE); ((nsBoxLayout *)(mRootCanvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical); + NS_RELEASE(calmodel); }