From e95759d1ac8cd17721963bec422ccaecacdfe061 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Sun, 19 Sep 2004 09:19:43 +0000 Subject: [PATCH] Bug 93426 New followups/replies were still being appended to the wrong parent partly due to my not unbitrotting the original patch correctly r+sr=bienvenu --- mailnews/base/src/nsMsgDBView.cpp | 20 +++++++------------- mailnews/base/src/nsMsgDBView.h | 2 +- mailnews/base/src/nsMsgThreadedDBView.cpp | 7 ++++--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index beba9531422..975d5e3904a 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -4357,25 +4357,19 @@ PRBool nsMsgDBView::WantsThisThread(nsIMsgThread * /*threadHdr*/) return PR_TRUE; // default is to want all threads. } -nsMsgViewIndex nsMsgDBView::FindParentInThread(nsIMsgDBHdr *msgHdr, nsMsgViewIndex startOfThreadViewIndex) +nsMsgViewIndex nsMsgDBView::FindParentInThread(nsMsgKey parentKey, nsMsgViewIndex startOfThreadViewIndex) { - nsCOMPtr curMsgHdr; - nsMsgKey parentKey; - msgHdr->GetThreadParent(&parentKey); - + nsCOMPtr msgHdr; while (parentKey != nsMsgKey_None) { - if (NS_FAILED(m_db->GetMsgHdrForKey(parentKey, getter_AddRefs(curMsgHdr)))) - break; - - nsMsgKey parentKey; - curMsgHdr->GetThreadParent(&parentKey); - if (parentKey == nsMsgKey_None) - break; - nsMsgViewIndex parentIndex = m_keys.FindIndex(parentKey, startOfThreadViewIndex); if (parentIndex != nsMsgViewIndex_None) return parentIndex; + + if (NS_FAILED(m_db->GetMsgHdrForKey(parentKey, getter_AddRefs(msgHdr)))) + break; + + msgHdr->GetThreadParent(&parentKey); } return startOfThreadViewIndex; diff --git a/mailnews/base/src/nsMsgDBView.h b/mailnews/base/src/nsMsgDBView.h index d74bbe4c962..c7d87be1ace 100644 --- a/mailnews/base/src/nsMsgDBView.h +++ b/mailnews/base/src/nsMsgDBView.h @@ -228,7 +228,7 @@ protected: nsresult ListIdsInThread(nsIMsgThread *threadHdr, nsMsgViewIndex viewIndex, PRUint32 *pNumListed); nsresult ListUnreadIdsInThread(nsIMsgThread *threadHdr, nsMsgViewIndex startOfThreadViewIndex, PRUint32 *pNumListed); - nsMsgViewIndex FindParentInThread(nsIMsgDBHdr *msgHdr, nsMsgViewIndex startOfThreadViewIndex); + nsMsgViewIndex FindParentInThread(nsMsgKey parentKey, nsMsgViewIndex startOfThreadViewIndex); nsresult ListIdsInThreadOrder(nsIMsgThread *threadHdr, nsMsgKey parentKey, PRInt32 level, nsMsgViewIndex *viewIndex, PRUint32 *pNumListed); PRInt32 GetSize(void) {return(m_keys.GetSize());} diff --git a/mailnews/base/src/nsMsgThreadedDBView.cpp b/mailnews/base/src/nsMsgThreadedDBView.cpp index f70bd5ae3ef..d99ed89ecf7 100644 --- a/mailnews/base/src/nsMsgThreadedDBView.cpp +++ b/mailnews/base/src/nsMsgThreadedDBView.cpp @@ -595,15 +595,16 @@ nsresult nsMsgThreadedDBView::OnNewHeader(nsIMsgDBHdr *newHdr, nsMsgKey aParentK // levels of other hdrs may have changed! PRUint32 newFlags = msgFlags; PRInt32 level = 0; - nsMsgViewIndex insertIndex = FindParentInThread(newHdr, threadIndex); + nsMsgViewIndex insertIndex = threadIndex; if (aParentKey == nsMsgKey_None) { newFlags |= MSG_VIEW_FLAG_ISTHREAD | MSG_VIEW_FLAG_HASCHILDREN; } else { - level = m_levels[insertIndex]; - insertIndex = GetInsertInfoForNewHdr(newHdr, threadIndex, level); + nsMsgViewIndex parentIndex = FindParentInThread(aParentKey, threadIndex); + level = m_levels[parentIndex] + 1; + insertIndex = GetInsertInfoForNewHdr(newHdr, parentIndex, level); } m_keys.InsertAt(insertIndex, newKey); m_flags.InsertAt(insertIndex, newFlags, 1);