From a6f01c6a79da008e751cf7abb34d1237feb749ec Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Thu, 14 Jan 1999 10:25:21 +0000 Subject: [PATCH] Fixed aDocListener bustage for tree control. git-svn-id: svn://10.0.0.236/branches/RDF_19990113_BRANCH@17735 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/rdf/content/src/nsRDFDocument.cpp | 31 +++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mozilla/rdf/content/src/nsRDFDocument.cpp b/mozilla/rdf/content/src/nsRDFDocument.cpp index 2bf03b32461..2785980c41e 100644 --- a/mozilla/rdf/content/src/nsRDFDocument.cpp +++ b/mozilla/rdf/content/src/nsRDFDocument.cpp @@ -477,7 +477,14 @@ RDFDocumentImpl::RDFDocumentImpl(void) RDFDocumentImpl::~RDFDocumentImpl() { - NS_IF_RELEASE(mDocumentDataSource); + if (mDocumentDataSource) { + nsIRDFXMLDocument* doc; + if (NS_SUCCEEDED(mDocumentDataSource->QueryInterface(kIRDFXMLDocumentIID, (void**) &doc))) { + doc->RemoveDocumentObserver(this); + NS_RELEASE(doc); + } + NS_RELEASE(mDocumentDataSource); + } NS_IF_RELEASE(mLocalDataSource); if (mResources) @@ -663,15 +670,17 @@ RDFDocumentImpl::StartDocumentLoad(nsIURL *aURL, // What I guess I'm saying is, maybe it doesn't make that much // sense to register stream data sources when they're // created...I dunno... - nsIStreamListener* lsnr = new DummyListener(this); - if (! lsnr) - return NS_ERROR_OUT_OF_MEMORY; + if (aDocListener) { + nsIStreamListener* lsnr = new DummyListener(this); + if (! lsnr) + return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(lsnr); - *aDocListener = lsnr; + NS_ADDREF(lsnr); + *aDocListener = lsnr; - if (NS_FAILED(rv = NS_OpenURL(aURL, lsnr))) - return rv; + if (NS_FAILED(rv = NS_OpenURL(aURL, lsnr))) + return rv; + } } else if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kRDFStreamDataSourceCID, nsnull, @@ -690,13 +699,15 @@ RDFDocumentImpl::StartDocumentLoad(nsIURL *aURL, nsIRDFXMLDocument* doc; if (NS_SUCCEEDED(rv = mDocumentDataSource->QueryInterface(kIRDFXMLDocumentIID, (void**) &doc))) { doc->AddDocumentObserver(this); + NS_RELEASE(doc); } if (NS_FAILED(rv = mDocumentDataSource->Init(uri))) return rv; - // XXX this may cause problems down the road - *aDocListener = nsnull; + if (aDocListener) { + *aDocListener = nsnull; + } } else { // an error occurred