diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index 207ec579d4b..dd504c513aa 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -1032,6 +1032,17 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, so inplaceSortCallback, (void *)sortInfo); } + // Bug 6665. This is a hack to "addref" the resources + // before we remove them from the content model. This + // keeps them from getting released, which causes + // performance problems for some datasources. + for (loop = 0; loop < numElements; loop++) + { + nsIRDFResource* resource; + nsRDFContentUtils::GetElementResource(flatArray[loop], &resource); + // Note that we don't release; see part deux below... + } + RemoveAllChildren(container); if (NS_FAILED(rv = container->UnsetAttribute(kNameSpaceID_None, kTreeContentsGeneratedAtom, @@ -1047,6 +1058,16 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, so container->InsertChildAt((nsIContent *)flatArray[loop], numChildren++, PR_FALSE); } + // Bug 6665, part deux. The Big Hack. + for (loop = 0; loop < numElements; loop++) + { + nsIRDFResource* resource; + nsRDFContentUtils::GetElementResource(flatArray[loop], &resource); + nsrefcnt refcnt; + NS_RELEASE2(resource, refcnt); + NS_RELEASE(resource); + } + // recurse on grandchildren for (loop=0; loopUnsetAttribute(kNameSpaceID_None, kTreeContentsGeneratedAtom, @@ -1047,6 +1058,16 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, so container->InsertChildAt((nsIContent *)flatArray[loop], numChildren++, PR_FALSE); } + // Bug 6665, part deux. The Big Hack. + for (loop = 0; loop < numElements; loop++) + { + nsIRDFResource* resource; + nsRDFContentUtils::GetElementResource(flatArray[loop], &resource); + nsrefcnt refcnt; + NS_RELEASE2(resource, refcnt); + NS_RELEASE(resource); + } + // recurse on grandchildren for (loop=0; loop