Fix mail crashes. Approved for checkin by leaf.

This commit is contained in:
putterman%netscape.com 1999-09-21 17:53:25 +00:00
Родитель efff4a9f90
Коммит 25cf84cfac
2 изменённых файлов: 25 добавлений и 19 удалений

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

@ -47,10 +47,6 @@ public:
nsRDFResource(void);
virtual ~nsRDFResource(void);
protected:
static nsIRDFService* gRDFService;
static nsrefcnt gRDFServiceRefCnt;
protected:
char* mURI;
};

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

@ -27,8 +27,7 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsIRDFService* nsRDFResource::gRDFService = nsnull;
nsrefcnt nsRDFResource::gRDFServiceRefCnt = 0;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@ -40,18 +39,21 @@ nsRDFResource::nsRDFResource(void)
nsRDFResource::~nsRDFResource(void)
{
nsIRDFService* rdfService = nsnull;
nsresult rv = NS_OK;
gRDFService->UnregisterResource(this);
rv = nsServiceManager::GetService(kRDFServiceCID,
nsIRDFService::GetIID(),
(nsISupports**) &rdfService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_SUCCEEDED(rv) && rdfService != nsnull) {
rdfService->UnregisterResource(this);
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
}
// N.B. that we need to free the URI *after* we un-cache the resource,
// due to the way that the resource manager is implemented.
nsCRT::free(mURI);
if (--gRDFServiceRefCnt == 0) {
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
}
NS_IMPL_ADDREF(nsRDFResource)
@ -118,16 +120,24 @@ nsRDFResource::Init(const char* aURI)
PL_strcpy(mURI, aURI);
nsIRDFService* rdfService = nsnull;
nsresult rv = NS_OK;
if (gRDFServiceRefCnt++ == 0) {
rv = nsServiceManager::GetService(kRDFServiceCID,
nsIRDFService::GetIID(),
(nsISupports**)&gRDFService);
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kRDFServiceCID,
nsIRDFService::GetIID(),
(nsISupports**) &rdfService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (!NS_SUCCEEDED(rv)) {
return rv;
}
if (rdfService == nsnull) {
return NS_ERROR_NULL_POINTER;
}
// don't replace an existing resource with the same URI automatically
return gRDFService->RegisterResource(this, PR_TRUE);
rv = rdfService->RegisterResource(this, PR_TRUE);
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
return rv;
}
NS_IMETHODIMP