From d399f0104e8a85ff68db7076707267d68fccd393 Mon Sep 17 00:00:00 2001 From: "dp%netscape.com" Date: Thu, 23 Sep 1999 00:14:00 +0000 Subject: [PATCH] UnloadAll() on non-native loaders. git-svn-id: svn://10.0.0.236/trunk@48882 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpcom/components/nsComponentManager.cpp | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index f9d6b02fabf..c38a8804572 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -1866,6 +1866,32 @@ nsComponentManagerImpl::UnregisterComponentSpec(const nsCID &aClass, return res; } +struct CanUnload_closure { + int when; + nsresult status; // this is a hack around Enumerate's void return + nsIComponentLoader *native; +}; + +static PRBool +CanUnload_enumerate(nsHashKey *key, void *aData, void *aClosure) +{ + nsIComponentLoader *loader = (nsIComponentLoader *)aData; + struct CanUnload_closure *closure = + (struct CanUnload_closure *)aClosure; + + if (loader == closure->native) { +#ifdef DEBUG + fprintf(stderr, "CanUnload_enumerate: skipping native\n"); +#endif + return PR_TRUE; + } + + closure->status = loader->UnloadAll(closure->when); + if (NS_FAILED(closure->status)) + return PR_FALSE; + return PR_TRUE; +} + nsresult nsComponentManagerImpl::FreeLibraries(void) { @@ -1887,7 +1913,13 @@ nsComponentManagerImpl::UnloadLibraries(nsIServiceManager *serviceMgr) PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("nsComponentManager: Unloading Libraries.")); - // XXX UnloadAll the loaders + // UnloadAll the loaders + /* iterate over all known loaders and ask them to autoregister. */ + struct CanUnload_closure closure; + closure.when = NS_Timer; + closure.status = NS_OK; + closure.native = mNativeComponentLoader; + mLoaders->Enumerate(CanUnload_enumerate, &closure); // UnloadAll the native loader rv = mNativeComponentLoader->UnloadAll(NS_Timer);