From 5585934f9b1a9d578e3d622e0d0ec188a203d8b2 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Wed, 30 Oct 2002 00:57:40 +0000 Subject: [PATCH] fix to make unregistering a category work. r=rginda, sr=dveditz, b=177176 m a=robert@ocallahan.org --- xpcom/components/nsCategoryManager.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index c62b5319c51..dc703564ade 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -42,7 +42,6 @@ #include "nsCOMPtr.h" #include "nsHashtable.h" #include "nsIFactory.h" -#include "nsIRegistry.h" #include "nsSupportsPrimitives.h" #include "nsIObserver.h" #include "nsComponentManager.h" @@ -62,6 +61,9 @@ Leaf nodes are strings. */ +// this function is not public yet, hence it is externed here. +extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result); + static NS_IMETHODIMP @@ -270,8 +272,6 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName, nsCStringKey entryNameKey(aEntryName); category->Put(&entryNameKey, entry); - // this function is not public yet, hence it is externed here. - extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result); nsCOMPtr mgr; NS_GetComponentLoaderManager(getter_AddRefs(mgr)); if (mgr) @@ -303,6 +303,12 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName, { nsCStringKey entryKey(aEntryName); category->RemoveAndDelete(&entryKey); + + nsCOMPtr mgr; + NS_GetComponentLoaderManager(getter_AddRefs(mgr)); + if (mgr) + mgr->FlushPersistentStore(PR_FALSE); + } return NS_OK; @@ -315,6 +321,11 @@ nsCategoryManager::DeleteCategory( const char *aCategoryName ) { NS_ASSERTION(aCategoryName, "aCategoryName is NULL!"); + nsCOMPtr mgr; + NS_GetComponentLoaderManager(getter_AddRefs(mgr)); + if (mgr) + mgr->FlushPersistentStore(PR_FALSE); + // QUESTION: consider whether this should be an error nsCStringKey categoryKey(aCategoryName); return RemoveAndDelete(&categoryKey) ? NS_OK : NS_ERROR_NOT_AVAILABLE;