From 8a37a5afc1f5a7d59a711ae3e9b97fcc379d7376 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Wed, 16 Jun 1999 02:07:56 +0000 Subject: [PATCH] Bug 6665. Hack to addref resources before doing the sort. This saves mailnews from having to recreate them. --- .../xul/templates/src/nsXULSortService.cpp | 21 +++++++++++++++++++ rdf/content/src/nsXULSortService.cpp | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) 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