Bug 664452, unlink XUL some more, r=peterv

--HG--
extra : rebase_source : e17e5ed7c6a5d6565758ce2835df559b6abdcf32
This commit is contained in:
Olli Pettay 2011-07-01 17:02:04 +03:00
Родитель d50c48a59f
Коммит c8b469ea2c
6 изменённых файлов: 64 добавлений и 11 удалений

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

@ -391,6 +391,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULDocument, nsXMLDocument)
delete tmp->mTemplateBuilderTable;
tmp->mTemplateBuilderTable = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCommandDispatcher)
//XXX We should probably unlink all the objects we traverse.
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

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

@ -190,13 +190,20 @@ nsXULPrototypeDocument::~nsXULPrototypeDocument()
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsXULPrototypeDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULPrototypeDocument)
tmp->mPrototypeWaiters.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULPrototypeDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mRoot,
nsXULPrototypeElement)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mGlobalObject");
cb.NoteXPCOMChild(static_cast<nsIScriptGlobalObject*>(tmp->mGlobalObject));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,
nsNodeInfoManager)
for (PRUint32 i = 0; i < tmp->mPrototypeWaiters.Length(); ++i) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mPrototypeWaiters[i]");
cb.NoteXPCOMChild(static_cast<nsINode*>(tmp->mPrototypeWaiters[i].get()));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULPrototypeDocument)

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

@ -81,9 +81,15 @@ public:
mQuerySetPriority(aQuerySetPriority),
mContainer(aContainer),
mResult(aResult),
mNext(nsnull) {}
mNext(nsnull)
{
MOZ_COUNT_CTOR(nsTemplateMatch);
}
~nsTemplateMatch() {}
~nsTemplateMatch()
{
MOZ_COUNT_DTOR(nsTemplateMatch);
}
static nsTemplateMatch*
Create(nsFixedSizeAllocator& aPool,

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

@ -275,6 +275,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateBuilder)
if (tmp->mMatchMap.IsInitialized()) {
tmp->mMatchMap.Enumerate(DestroyMatchList, &(tmp->mPool));
}
for (PRUint32 i = 0; i < tmp->mQuerySets.Length(); ++i) {
nsTemplateQuerySet* qs = tmp->mQuerySets[i];
delete qs;
}
tmp->mQuerySets.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDataSource)

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

@ -86,7 +86,9 @@ nsIRDFResource* nsXULTemplateQueryProcessorRDF::kNC_BookmarkSeparator;
nsIRDFResource* nsXULTemplateQueryProcessorRDF::kRDF_type;
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemplateQueryProcessorRDF)
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsXULTemplateQueryProcessorRDF)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorRDF)
tmp->Done();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
static PLDHashOperator
BindingDependenciesTraverser(nsISupports* key,
@ -1056,7 +1058,7 @@ nsXULTemplateQueryProcessorRDF::SynchronizeAll(nsIRDFResource* aSource,
// Get all the matches whose assignments are currently supported
// by aSource and aProperty: we'll need to recompute them.
nsCOMArray<nsXULTemplateResultRDF>* results;
if (!mBindingDependencies.Get(aSource, &results))
if (!mBindingDependencies.Get(aSource, &results) || !mBuilder)
return NS_OK;
PRUint32 length = results->Count();
@ -1125,6 +1127,7 @@ nsXULTemplateQueryProcessorRDF::CheckContainer(nsIRDFResource* aResource,
PRBool* aIsContainer)
{
NS_ENSURE_ARG_POINTER(aIsContainer);
NS_ENSURE_STATE(mDB);
// We have to look at all of the arcs extending out of the
// resource: if any of them are that "containment" property, then
@ -1159,6 +1162,7 @@ nsresult
nsXULTemplateQueryProcessorRDF::CheckEmpty(nsIRDFResource* aResource,
PRBool* aIsEmpty)
{
NS_ENSURE_STATE(mDB);
*aIsEmpty = PR_TRUE;
for (nsResourceSet::ConstIterator property = mContainmentProperties.First();
@ -1186,6 +1190,7 @@ nsresult
nsXULTemplateQueryProcessorRDF::CheckIsSeparator(nsIRDFResource* aResource,
PRBool* aIsSeparator)
{
NS_ENSURE_STATE(mDB);
return mDB->HasAssertion(aResource, kRDF_type, kNC_BookmarkSeparator,
PR_TRUE, aIsSeparator);
}
@ -1903,7 +1908,7 @@ nsXULTemplateQueryProcessorRDF::GetContainerIndexOf(nsIXULTemplateResult* aResul
nsCOMPtr<nsISupports> ref;
nsresult rv = aResult->GetBindingObjectFor(mRefVariable,
getter_AddRefs(ref));
if (NS_FAILED(rv))
if (NS_FAILED(rv) || !mDB)
return -1;
nsCOMPtr<nsIRDFResource> container = do_QueryInterface(ref);
@ -1940,7 +1945,7 @@ nsXULTemplateQueryProcessorRDF::GetSortValue(nsIXULTemplateResult* aResult,
return rv;
nsCOMPtr<nsIRDFNode> value;
if (source) {
if (source && mDB) {
// first check predicate?sort=true so that datasources may use a
// custom value for sorting
rv = mDB->GetTarget(source, aSortPredicate, PR_TRUE,

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

@ -81,6 +81,7 @@ class nsXULTreeBuilder : public nsXULTemplateBuilder,
public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
// nsIXULTreeBuilder
NS_DECL_NSIXULTREEBUILDER
@ -304,15 +305,42 @@ NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult)
return rv;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTreeBuilder)
NS_IMPL_ADDREF_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
NS_IMPL_RELEASE_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBoxObject)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSelection)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPersistStateStore)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mObservers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
static PRBool TraverseObservers(nsISupports* aElement, void *aData)
{
nsCycleCollectionTraversalCallback *cb =
static_cast<nsCycleCollectionTraversalCallback*>(aData);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mObservers[i]");
cb->NoteXPCOMChild(aElement);
return PR_TRUE;
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBoxObject)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSelection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPersistStateStore)
if (tmp->mObservers) {
tmp->mObservers->EnumerateForwards(TraverseObservers, &cb);
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
DOMCI_DATA(XULTreeBuilder, nsXULTreeBuilder)
NS_INTERFACE_MAP_BEGIN(nsXULTreeBuilder)
NS_INTERFACE_MAP_ENTRY(nsIXULTreeBuilder)
NS_INTERFACE_MAP_ENTRY(nsITreeView)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULTreeBuilder)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXULTreeBuilder)
NS_INTERFACE_MAP_ENTRY(nsIXULTreeBuilder)
NS_INTERFACE_MAP_ENTRY(nsITreeView)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULTreeBuilder)
NS_INTERFACE_MAP_END_INHERITING(nsXULTemplateBuilder)