Removing shutdown listener. Releasing gCaseConv on XPCOM Shutdown r=kipp

This commit is contained in:
dp%netscape.com 1999-10-30 06:45:45 +00:00
Родитель d120ed2e68
Коммит c2288cca73
2 изменённых файлов: 14 добавлений и 40 удалений

Просмотреть файл

@ -57,6 +57,10 @@
#include "nsLeakDetector.h"
#endif
// Include files that dont reside under xpcom
// Our goal was to make this zero. But... :-(
#include "nsICaseConversion.h"
// base
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
// ds
@ -153,9 +157,11 @@ RegisterGenericFactory(nsIComponentManager* compMgr, const nsCID& cid, const cha
return rv;
}
// Globals in xpcom
nsIServiceManager* nsServiceManager::mGlobalServiceManager = NULL;
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
static nsFileSpec registryDirName;
nsICaseConversion *gCaseConv = NULL;
nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
nsFileSpec *registryFile, nsFileSpec *componentDir)
@ -503,6 +509,9 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr)
NS_RELEASE2(nsServiceManager::mGlobalServiceManager, cnt);
NS_ASSERTION(cnt == 0, "Service Manager being held past XPCOM shutdown.");
// Release the global case converter
NS_IF_RELEASE(gCaseConv);
#if defined(DEBUG_shaver) || defined(DEBUG_dp)
/* shaver needs to fix this and turn this on for the world */

Просмотреть файл

@ -118,52 +118,17 @@ static const unsigned char kLower2Upper[256] = {
#define TOUPPER(_ucs2) \
(((_ucs2) < 128) ? PRUnichar(kLower2Upper[_ucs2]) : _ToUpper(_ucs2))
class HandleCaseConversionShutdown : public nsIShutdownListener {
public :
NS_IMETHOD OnShutdown(const nsCID& cid, nsISupports* service);
HandleCaseConversionShutdown(void) { NS_INIT_REFCNT(); }
virtual ~HandleCaseConversionShutdown(void) {}
NS_DECL_ISUPPORTS
};
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
static nsICaseConversion * gCaseConv = NULL;
extern nsICaseConversion * gCaseConv;
NS_IMPL_ISUPPORTS1(HandleCaseConversionShutdown, nsIShutdownListener)
nsresult
HandleCaseConversionShutdown::OnShutdown(const nsCID& cid,
nsISupports* aService)
{
if (cid.Equals(kUnicharUtilCID)) {
NS_ASSERTION(aService == gCaseConv, "wrong service!");
gCaseConv->Release();
gCaseConv = NULL;
}
return NS_OK;
}
static HandleCaseConversionShutdown* gListener = NULL;
static void StartUpCaseConversion()
{
nsresult err;
if ( NULL == gListener )
{
gListener = new HandleCaseConversionShutdown();
gListener->AddRef();
}
err = nsServiceManager::GetService(kUnicharUtilCID, NS_GET_IID(nsICaseConversion),
(nsISupports**) &gCaseConv, gListener);
}
static void CheckCaseConversion()
{
if (NULL == gCaseConv)
StartUpCaseConversion();
(void) nsServiceManager::GetService(kUnicharUtilCID, NS_GET_IID(nsICaseConversion),
(nsISupports**) &gCaseConv);
NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
}
static PRUnichar _ToLower(PRUnichar aChar)