From 34b2bf3ffdd1bc731230c2272077482a2e7183b7 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Mon, 17 Oct 2005 05:18:36 +0000 Subject: [PATCH] fix dups in threaded quick search view when not sorted by id, sr/a=mscott 312598 git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@182367 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/base/src/nsMsgQuickSearchDBView.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mozilla/mailnews/base/src/nsMsgQuickSearchDBView.cpp b/mozilla/mailnews/base/src/nsMsgQuickSearchDBView.cpp index 620daf398ba..cdf8d8ab40b 100644 --- a/mozilla/mailnews/base/src/nsMsgQuickSearchDBView.cpp +++ b/mozilla/mailnews/base/src/nsMsgQuickSearchDBView.cpp @@ -297,16 +297,23 @@ nsresult nsMsgQuickSearchDBView::SortThreads(nsMsgViewSortTypeValue sortType, ns continue; // it would be nice if GetInsertIndexHelper always found the hdr, but it doesn't. threadHdr->GetChildHdrAt(0, getter_AddRefs(rootHdr)); - threadRootIndex = GetInsertIndexHelper(rootHdr, &threadRootIds, nsMsgViewSortOrder::ascending, sortType); + threadRootIndex = GetInsertIndexHelper(rootHdr, &threadRootIds, nsMsgViewSortOrder::ascending, nsMsgViewSortType::byId); threadRootIds.InsertAt(threadRootIndex, rootKey); } } - // now we've build up the list of thread ids - need to build the view - // from that. So for each thread id, we need to list the messages in the thread. m_origKeys.CopyArray(m_keys); + // need to sort the top level threads now by sort order, if it's not by id. + if (sortType != nsMsgViewSortType::byId) + { + m_keys.CopyArray(threadRootIds); + nsMsgDBView::Sort(sortType, sortOrder); + threadRootIds.CopyArray(m_keys); + } m_keys.RemoveAll(); m_levels.RemoveAll(); m_flags.RemoveAll(); + // now we've build up the list of thread ids - need to build the view + // from that. So for each thread id, we need to list the messages in the thread. PRUint32 numThreads = threadRootIds.GetSize(); for (PRUint32 threadIndex = 0; threadIndex < numThreads; threadIndex++) { @@ -333,6 +340,7 @@ nsresult nsMsgQuickSearchDBView::SortThreads(nsMsgViewSortTypeValue sortType, ns } } } + NS_ASSERTION(m_origKeys.GetSize() == m_keys.GetSize(), "problem threading quick search"); return NS_OK; }