From 2bf48699238ef1bcb4acec22668def94737d73ca Mon Sep 17 00:00:00 2001 From: "cata%netscape.com" Date: Thu, 13 Jan 2000 23:18:35 +0000 Subject: [PATCH] Various small fixes. r=erik --- intl/strres/src/nsStringBundle.cpp | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/intl/strres/src/nsStringBundle.cpp b/intl/strres/src/nsStringBundle.cpp index 3f87105a0670..88e62110c309 100644 --- a/intl/strres/src/nsStringBundle.cpp +++ b/intl/strres/src/nsStringBundle.cpp @@ -340,6 +340,7 @@ NS_IMPL_ISUPPORTS(nsExtensibleStringBundle, NS_GET_IID(nsIStringBundle)); nsExtensibleStringBundle::nsExtensibleStringBundle(const char * aRegistryKey, nsILocale * aLocale, nsresult * aResult) + :mBundle(NULL) { NS_INIT_REFCNT(); @@ -348,6 +349,7 @@ nsExtensibleStringBundle::nsExtensibleStringBundle(const char * aRegistryKey, nsIRegistry * registry = NULL; nsRegistryKey uconvKey, key; nsIStringBundleService * sbServ = NULL; + PRBool regOpen = PR_FALSE; // get the Bundle Service res = nsServiceManager::GetService(kStringBundleServiceCID, @@ -359,6 +361,13 @@ nsExtensibleStringBundle::nsExtensibleStringBundle(const char * aRegistryKey, NS_GET_IID(nsIRegistry), (nsISupports**)®istry); if (NS_FAILED(res)) goto done; + // open registry if necessary + registry->IsOpen(®Open); + if (!regOpen) { + res = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry); + if (NS_FAILED(res)) goto done; + } + // get subtree res = registry->GetSubtree(nsIRegistry::Common, aRegistryKey, &uconvKey); @@ -420,6 +429,8 @@ done: kStringBundleServiceCID, sbServ); NS_IF_RELEASE(components); + + *aResult = res; } nsExtensibleStringBundle::~nsExtensibleStringBundle() @@ -607,6 +618,32 @@ nsStringBundleService::CreateXPCBundle(const char *aURLSpec, const PRUnichar *aL return ret; } +NS_IMETHODIMP +NS_NewStringBundleService(nsISupports* aOuter, const nsIID& aIID, + void** aResult) +{ + nsresult rv; + + if (!aResult) { + return NS_ERROR_INVALID_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsStringBundleService * inst = new nsStringBundleService(); + if (inst == NULL) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + rv = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(rv)) { + delete inst; + *aResult = nsnull; + } + return rv; +} + NS_GENERIC_FACTORY_CONSTRUCTOR(nsStringBundleService) static nsModuleComponentInfo components[] =