From 696b4aaa5cd2d50c1e289f9a0f28cef0893079a0 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Sat, 2 Dec 2006 00:41:06 +0000 Subject: [PATCH] fix 361150 message aging with grouped view crashing, sr=mscott --- mailnews/base/src/nsMsgGroupView.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mailnews/base/src/nsMsgGroupView.cpp b/mailnews/base/src/nsMsgGroupView.cpp index f23c554f5455..a8ecca74fbfa 100755 --- a/mailnews/base/src/nsMsgGroupView.cpp +++ b/mailnews/base/src/nsMsgGroupView.cpp @@ -324,7 +324,8 @@ nsMsgGroupThread *nsMsgGroupView::AddHdrToThread(nsIMsgDBHdr *msgHdr, PRBool *pN // check if new hdr became thread root if (!newThread && foundThread->m_keys[0] == msgKey) { - m_keys.SetAt(viewIndexOfThread, msgKey); + if (viewIndexOfThread != nsMsgKey_None) + m_keys.SetAt(viewIndexOfThread, msgKey); if (GroupViewUsesDummyRow()) foundThread->m_keys.SetAt(1, msgKey); // replace the old duplicate dummy header. } @@ -558,18 +559,22 @@ NS_IMETHODIMP nsMsgGroupView::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aP nsMsgGroupThread *groupThread = NS_STATIC_CAST(nsMsgGroupThread *, (nsIMsgThread *) thread); - PRBool rootDeleted = m_keys.GetAt(viewIndexOfThread) == keyDeleted; + PRBool rootDeleted = viewIndexOfThread != nsMsgKey_None && + m_keys.GetAt(viewIndexOfThread) == keyDeleted; rv = nsMsgDBView::OnHdrDeleted(aHdrDeleted, aParentKey, aFlags, aInstigator); if (groupThread->m_dummy) { if (!groupThread->NumRealChildren()) { thread->RemoveChildAt(0); // get rid of dummy - nsMsgDBView::RemoveByIndex(viewIndexOfThread - 1); - if (m_deletingRows) - mIndicesToNoteChange.Add(viewIndexOfThread - 1); + if (viewIndexOfThread != nsMsgKey_None) + { + nsMsgDBView::RemoveByIndex(viewIndexOfThread - 1); + if (m_deletingRows) + mIndicesToNoteChange.Add(viewIndexOfThread - 1); + } } - else if (rootDeleted) + else if (rootDeleted && viewIndexOfThread > 0) { m_keys.SetAt(viewIndexOfThread - 1, m_keys.GetAt(viewIndexOfThread)); OrExtraFlag(viewIndexOfThread - 1, MSG_VIEW_FLAG_DUMMY | MSG_VIEW_FLAG_ISTHREAD);