Fixed some refcounting and initialization bugs.

This commit is contained in:
waterson%netscape.com 1999-02-02 07:06:56 +00:00
Родитель 40c78e8a96
Коммит dc47ab867a
1 изменённых файлов: 9 добавлений и 3 удалений

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

@ -404,13 +404,15 @@ NS_NewRDFXMLDataSource(nsIRDFXMLDataSource** result)
RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void) RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void)
: mIsSynchronous(PR_FALSE), : mInner(nsnull),
mIsSynchronous(PR_FALSE),
mIsWritable(PR_TRUE), mIsWritable(PR_TRUE),
mIsDirty(PR_FALSE), mIsDirty(PR_FALSE),
mNamedDataSourceURIs(nsnull), mNamedDataSourceURIs(nsnull),
mNumNamedDataSourceURIs(0), mNumNamedDataSourceURIs(0),
mCSSStyleSheetURLs(nsnull), mCSSStyleSheetURLs(nsnull),
mNumCSSStyleSheetURLs(0), mNumCSSStyleSheetURLs(0),
mRootResource(nsnull),
mIsLoading(PR_FALSE), mIsLoading(PR_FALSE),
mNameSpaces(nsnull) mNameSpaces(nsnull)
{ {
@ -465,6 +467,9 @@ RDFXMLDataSourceImpl::~RDFXMLDataSourceImpl(void)
NS_RELEASE(doomed->Prefix); NS_RELEASE(doomed->Prefix);
delete doomed; delete doomed;
} }
NS_IF_RELEASE(mRootResource);
NS_RELEASE(mInner);
} }
@ -789,8 +794,9 @@ RDFXMLDataSourceImpl::SetRootResource(nsIRDFResource* aResource)
if (! aResource) if (! aResource)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
NS_ADDREF(aResource); NS_IF_RELEASE(mRootResource);
mRootResource = aResource; mRootResource = aResource;
NS_IF_ADDREF(mRootResource);
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) { for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
nsIRDFXMLDataSourceObserver* obs = (nsIRDFXMLDataSourceObserver*) mObservers[i]; nsIRDFXMLDataSourceObserver* obs = (nsIRDFXMLDataSourceObserver*) mObservers[i];
@ -802,7 +808,7 @@ RDFXMLDataSourceImpl::SetRootResource(nsIRDFResource* aResource)
NS_IMETHODIMP NS_IMETHODIMP
RDFXMLDataSourceImpl::GetRootResource(nsIRDFResource** aResource) RDFXMLDataSourceImpl::GetRootResource(nsIRDFResource** aResource)
{ {
NS_ADDREF(mRootResource); NS_IF_ADDREF(mRootResource);
*aResource = mRootResource; *aResource = mRootResource;
return NS_OK; return NS_OK;
} }