From 1b9183448dc49afb66930f63a5e0baec6602d656 Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Fri, 15 Oct 1999 21:14:43 +0000 Subject: [PATCH] Bug #15292, r=dp. Made the component manager inherit from |nsSupportsWeakReference|, fixed its |QueryInterface()| appropriately, and added casts in two places that became ambiguous now that the component manager had multiple |nsISupports| in it. Now one can hold a weak reference to the component manager using |nsIWeakReference|. --- xpcom/build/nsXPComInit.cpp | 2 +- xpcom/components/nsComponentManager.cpp | 2 +- xpcom/components/nsComponentManager.h | 3 ++- xpcom/components/nsNativeComponentLoader.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 5b6373cd1a7..2c192d32504 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -206,7 +206,7 @@ nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result, nsComponentManagerImpl::gComponentManager = compMgr; } - rv = servMgr->RegisterService(kComponentManagerCID, compMgr); + rv = servMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr)); if (NS_FAILED(rv)) return rv; // 3. Register the global services with the component manager so that diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 57f1228f5c5..f0ebd073c1d 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -290,7 +290,7 @@ nsComponentManagerImpl::~nsComponentManagerImpl() } -NS_IMPL_ISUPPORTS(nsComponentManagerImpl, NS_GET_IID(nsIComponentManager)); +NS_IMPL_ISUPPORTS2(nsComponentManagerImpl, nsIComponentManager, nsISupportsWeakReference) //////////////////////////////////////////////////////////////////////////////// // nsComponentManagerImpl: Platform methods diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index aad4b814638..d965f1abd8b 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -28,6 +28,7 @@ #include "prtime.h" #include "prmon.h" #include "nsCOMPtr.h" +#include "nsWeakReference.h" class nsFactoryEntry; class nsDll; @@ -44,7 +45,7 @@ extern const char XPCOM_LIB_PREFIX[]; //////////////////////////////////////////////////////////////////////////////// -class nsComponentManagerImpl : public nsIComponentManager { +class nsComponentManagerImpl : public nsIComponentManager, public nsSupportsWeakReference { public: NS_DECL_ISUPPORTS NS_DECL_NSICOMPONENTMANAGER diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index 60bbbf9d9ed..9e62ad1fe0d 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -365,7 +365,7 @@ nsFreeLibrary(nsDll *dll, nsIServiceManager *serviceMgr, PRInt32 when) // Get the module object nsCOMPtr mobj; /* XXXshaver cheat and use the global component manager */ - rv = dll->GetModule(nsComponentManagerImpl::gComponentManager, + rv = dll->GetModule(NS_STATIC_CAST(nsIComponentManager*, nsComponentManagerImpl::gComponentManager), getter_AddRefs(mobj)); if (NS_SUCCEEDED(rv)) {