From bded77e04f43f980439d6599bbeefaf2f07d0905 Mon Sep 17 00:00:00 2001 From: "jband%netscape.com" Date: Wed, 20 Feb 2002 07:03:27 +0000 Subject: [PATCH] fix bug 126333. reduce shutdown leakage by releaseing Components object members. r=dbradley sr=alecf git-svn-id: svn://10.0.0.236/trunk@115082 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/xpconnect/src/xpccomponents.cpp | 6 ++++++ mozilla/js/src/xpconnect/src/xpcprivate.h | 3 +++ mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/mozilla/js/src/xpconnect/src/xpccomponents.cpp b/mozilla/js/src/xpconnect/src/xpccomponents.cpp index 65177dc2408..13bcd746b92 100644 --- a/mozilla/js/src/xpconnect/src/xpccomponents.cpp +++ b/mozilla/js/src/xpconnect/src/xpccomponents.cpp @@ -1553,6 +1553,12 @@ nsXPCComponents::nsXPCComponents() } nsXPCComponents::~nsXPCComponents() +{ + ClearMembers(); +} + +void +nsXPCComponents::ClearMembers() { NS_IF_RELEASE(mInterfaces); NS_IF_RELEASE(mClasses); diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index 193f4bc898a..bfe0ff09df7 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -2808,10 +2808,13 @@ public: XPCWrappedNativeScope* aScope, JSObject* aGlobal); + void SystemIsBeingShutDown() {ClearMembers();} + virtual ~nsXPCComponents(); private: nsXPCComponents(); + void ClearMembers(); private: nsXPCComponents_Interfaces* mInterfaces; diff --git a/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp b/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp index f84ad357706..fd3755ecd5d 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp @@ -431,6 +431,10 @@ XPCWrappedNativeScope::SystemIsBeingShutDown(XPCCallContext& ccx) for(cur = gDyingScopes; cur; cur = cur->mNext) { + // Give the Components object a chance to try to clean up. + if(cur->mComponents) + cur->mComponents->SystemIsBeingShutDown(); + // Walk the protos first. Wrapper shutdown can leave dangling // proto pointers in the proto map. cur->mWrappedNativeProtoMap->