SetDocument(nsnull) is now valid, indicating document is going away. Timers are removed in this manner.

git-svn-id: svn://10.0.0.236/trunk@26625 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rjc%netscape.com 1999-04-07 00:27:40 +00:00
parent f6f9519099
commit 573cc8216d
4 changed files with 65 additions and 25 deletions

View File

@ -708,6 +708,32 @@ XULDocumentImpl::~XULDocumentImpl()
NS_RELEASE(subdoc);
}
// set all builder references to document to nsnull
if (mBuilders)
{
#ifdef DEBUG
printf("# of builders: %lu\n", (unsigned long)mBuilders->Count());
#endif
for (PRUint32 i = 0; i < mBuilders->Count(); ++i)
{
// XXX we should QueryInterface() here
nsIRDFContentModelBuilder* builder
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
NS_ASSERTION(builder != nsnull, "null ptr");
if (! builder)
continue;
nsresult rv = builder->SetDocument(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "error creating content");
// XXX ignore error code?
NS_RELEASE(builder);
}
}
NS_IF_RELEASE(mBuilders);
NS_IF_RELEASE(mXULBuilder);
NS_IF_RELEASE(mSelection);

View File

@ -214,24 +214,19 @@ done:
NS_IMETHODIMP
RDFHTMLBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
{
NS_PRECONDITION(aDocument != nsnull, "null ptr");
if (! aDocument)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(mDocument == nsnull, "already initialized");
if (mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
// note: document can now be null to indicate going away
mDocument = aDocument; // not refcounted
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
if (doc) {
nsCOMPtr<nsINameSpaceManager> mgr;
doc->GetNameSpaceManager( *getter_AddRefs(mgr) );
if (mgr) {
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
mgr->GetNameSpaceID(kRDFNameSpaceURI, kNameSpaceID_RDF);
}
if (aDocument != nsnull)
{
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
if (doc) {
nsCOMPtr<nsINameSpaceManager> mgr;
doc->GetNameSpaceManager( *getter_AddRefs(mgr) );
if (mgr) {
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
mgr->GetNameSpaceID(kRDFNameSpaceURI, kNameSpaceID_RDF);
}
}
}
return NS_OK;
}

View File

@ -407,14 +407,7 @@ RDFXULBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
NS_IMETHODIMP
RDFXULBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
{
NS_PRECONDITION(aDocument != nsnull, "null ptr");
if (! aDocument)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(mDocument == nsnull, "already initialized");
if (mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
// note: document can now be null to indicate its going away
mDocument = aDocument; // not refcounted
return NS_OK;
}

View File

@ -708,6 +708,32 @@ XULDocumentImpl::~XULDocumentImpl()
NS_RELEASE(subdoc);
}
// set all builder references to document to nsnull
if (mBuilders)
{
#ifdef DEBUG
printf("# of builders: %lu\n", (unsigned long)mBuilders->Count());
#endif
for (PRUint32 i = 0; i < mBuilders->Count(); ++i)
{
// XXX we should QueryInterface() here
nsIRDFContentModelBuilder* builder
= (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);
NS_ASSERTION(builder != nsnull, "null ptr");
if (! builder)
continue;
nsresult rv = builder->SetDocument(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "error creating content");
// XXX ignore error code?
NS_RELEASE(builder);
}
}
NS_IF_RELEASE(mBuilders);
NS_IF_RELEASE(mXULBuilder);
NS_IF_RELEASE(mSelection);