From e24e2ca787779e25d0adeaaff38510b34892a74f Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Tue, 21 Sep 2004 15:07:07 +0000 Subject: [PATCH] trunk version of fix for 231846 delete bug in threaded view, when switching from flat sort, sr=mscott git-svn-id: svn://10.0.0.236/trunk@162599 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/base/src/nsMsgThreadedDBView.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mozilla/mailnews/base/src/nsMsgThreadedDBView.cpp b/mozilla/mailnews/base/src/nsMsgThreadedDBView.cpp index d99ed89ecf7..32dc8c7b21f 100644 --- a/mozilla/mailnews/base/src/nsMsgThreadedDBView.cpp +++ b/mozilla/mailnews/base/src/nsMsgThreadedDBView.cpp @@ -201,7 +201,9 @@ nsresult nsMsgThreadedDBView::SortThreads(nsMsgViewSortTypeValue sortType, nsMsg m_viewFlags |= nsMsgViewFlagsType::kThreadedDisplay; DisableChangeUpdates(); // Loop through the original array, for each thread that's expanded, find it in the new array - // and expand the thread. + // and expand the thread. We have to update MSG_VIEW_FLAG_HAS_CHILDREN because + // we may be going from a flat sort, which doesn't maintain that flag, + // to a threaded sort, which requires that flag. for (PRUint32 j = 0; j < m_keys.GetSize(); j++) { PRUint32 flags = m_flags[j]; @@ -211,6 +213,25 @@ nsresult nsMsgThreadedDBView::SortThreads(nsMsgViewSortTypeValue sortType, nsMsg m_flags[j] = flags | MSG_FLAG_ELIDED; ExpandByIndex(j, &numExpanded); j += numExpanded; + if (numExpanded > 0) + m_flags[j - numExpanded] = flags | MSG_VIEW_FLAG_HASCHILDREN; + } + else if (flags & MSG_VIEW_FLAG_ISTHREAD && ! (flags & MSG_VIEW_FLAG_HASCHILDREN)) + { + nsCOMPtr msgHdr; + nsCOMPtr pThread; + m_db->GetMsgHdrForKey(m_keys[j], getter_AddRefs(msgHdr)); + if (msgHdr) + { + m_db->GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(pThread)); + if (pThread) + { + PRUint32 numChildren; + pThread->GetNumChildren(&numChildren); + if (numChildren > 1) + m_flags[j] = flags | MSG_VIEW_FLAG_HASCHILDREN | MSG_FLAG_ELIDED; + } + } } } EnableChangeUpdates();