From f2968646f459156ca012bad0938b2ccc129cdad8 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 26 Mar 2003 06:52:20 +0000 Subject: [PATCH] Don't leak nsBoxToBlockAdaptors (bug 177807). r=varga, sr=dbaron. git-svn-id: svn://10.0.0.236/trunk@140342 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/xul/base/src/nsBoxFrame.cpp | 8 +++----- mozilla/layout/xul/base/src/nsContainerBox.cpp | 7 +++++++ mozilla/layout/xul/base/src/nsContainerBox.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 8aa5413891c..c3ba720555b 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -1093,14 +1093,12 @@ nsBoxFrame::DoLayout(nsBoxLayoutState& aState) NS_IMETHODIMP nsBoxFrame::Destroy(nsIPresContext* aPresContext) { -// if we are root remove 1 from the debug count. - if (mState & NS_STATE_IS_ROOT) - GetDebugPref(aPresContext); - // unregister access key RegUnregAccessKey(aPresContext, PR_FALSE); - SetLayoutManager(nsnull); + // clean up the container box's layout manager and child boxes + nsBoxLayoutState state(aPresContext); + nsContainerBox::Destroy(state); return nsContainerFrame::Destroy(aPresContext); } diff --git a/mozilla/layout/xul/base/src/nsContainerBox.cpp b/mozilla/layout/xul/base/src/nsContainerBox.cpp index f93d6168f09..697307d4af2 100644 --- a/mozilla/layout/xul/base/src/nsContainerBox.cpp +++ b/mozilla/layout/xul/base/src/nsContainerBox.cpp @@ -85,6 +85,13 @@ nsContainerBox::~nsContainerBox() { } +void +nsContainerBox::Destroy(nsBoxLayoutState& aState) +{ + SetLayoutManager(nsnull); + ClearChildren(aState); +} + #ifdef DEBUG_LAYOUT void nsContainerBox::GetBoxName(nsAutoString& aName) diff --git a/mozilla/layout/xul/base/src/nsContainerBox.h b/mozilla/layout/xul/base/src/nsContainerBox.h index b895fc15cec..52cbc53101e 100644 --- a/mozilla/layout/xul/base/src/nsContainerBox.h +++ b/mozilla/layout/xul/base/src/nsContainerBox.h @@ -53,6 +53,8 @@ public: nsContainerBox(nsIPresShell* aShell); virtual ~nsContainerBox(); + void Destroy(nsBoxLayoutState& aState); + NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout); NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout); NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);