fix 264408, problems deleting the first message in a date group thread, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2004-10-14 21:18:45 +00:00
Родитель 50e1c3b789
Коммит cc2cd73250
2 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -167,7 +167,6 @@ nsresult nsMsgGroupThread::AddMsgHdrInDateOrder(nsIMsgDBHdr *child)
{
nsCOMPtr <nsIMsgDBHdr> topLevelHdr;
PRTime newHdrDate;
PRTime topLevelHdrDate;
PRBool done = PR_FALSE;
child->GetDate(&newHdrDate);
@ -426,7 +425,7 @@ NS_IMETHODIMP nsMsgGroupThread::RemoveChildHdr(nsIMsgDBHdr *child, nsIDBChangeAn
child->GetMessageKey(&key);
child->GetThreadParent(&threadParent);
ReparentChildrenOf(key, threadParent, announcer);
// ReparentChildrenOf(key, threadParent, announcer);
// if this was the newest msg, clear the newest msg date so we'll recalc.
PRUint32 date;
@ -434,9 +433,16 @@ NS_IMETHODIMP nsMsgGroupThread::RemoveChildHdr(nsIMsgDBHdr *child, nsIDBChangeAn
if (date == m_newestMsgDate)
SetNewestMsgDate(0);
if (!(flags & MSG_FLAG_READ))
if (!(flags & MSG_FLAG_READ))
ChangeUnreadChildCount(-1);
return RemoveChild(key);
PRBool keyWasFirstKey = (m_keys.GetAt(0) == key);
nsresult rv = RemoveChild(key);
// if we're deleting the root of a dummy thread, need to update the threadKey
// and the dummy header at position 0
if (m_dummy && keyWasFirstKey && m_keys.GetSize() > 1)
m_keys.SetAt(0, m_keys.GetAt(1));
return rv;
}
nsresult nsMsgGroupThread::ReparentChildrenOf(nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeAnnouncer *announcer)

Просмотреть файл

@ -402,6 +402,8 @@ NS_IMETHODIMP nsMsgGroupView::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aP
nsIDBChangeListener *aInstigator)
{
nsCOMPtr <nsIMsgThread> thread;
nsMsgKey keyDeleted;
aHdrDeleted->GetMessageKey(&keyDeleted);
nsresult rv = GetThreadContainingMsgHdr(aHdrDeleted, getter_AddRefs(thread));
NS_ENSURE_SUCCESS(rv, rv);
@ -409,12 +411,22 @@ NS_IMETHODIMP nsMsgGroupView::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aP
thread->RemoveChildHdr(aHdrDeleted, nsnull);
nsMsgGroupThread *groupThread = NS_STATIC_CAST(nsMsgGroupThread *, (nsIMsgThread *) thread);
PRBool rootDeleted = m_keys.GetAt(viewIndexOfThread) == keyDeleted;
rv = nsMsgDBView::OnHdrDeleted(aHdrDeleted, aParentKey, aFlags, aInstigator);
if (groupThread->m_dummy && !groupThread->NumRealChildren())
if (groupThread->m_dummy)
{
thread->RemoveChildAt(0); // get rid of dummy
nsMsgDBView::RemoveByIndex(viewIndexOfThread);
NoteChange(viewIndexOfThread, -1, nsMsgViewNotificationCode::insertOrDelete); // an example where view is not the listener - D&D messages
if (!groupThread->NumRealChildren())
{
thread->RemoveChildAt(0); // get rid of dummy
nsMsgDBView::RemoveByIndex(viewIndexOfThread);
NoteChange(viewIndexOfThread, -1, nsMsgViewNotificationCode::insertOrDelete); // an example where view is not the listener - D&D messages
}
else if (rootDeleted)
{
m_keys.SetAt(viewIndexOfThread, m_keys.GetAt(viewIndexOfThread + 1));
OrExtraFlag(viewIndexOfThread, MSG_VIEW_FLAG_DUMMY | MSG_VIEW_FLAG_ISTHREAD);
}
}
if (!groupThread->m_keys.GetSize())
{
@ -451,6 +463,7 @@ NS_IMETHODIMP nsMsgGroupView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol, nsA
{
nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsresult rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
NS_ENSURE_SUCCESS(rv, rv);
nsHashKey *hashKey = AllocHashKeyForHdr(msgHdr);
if (!hashKey)
return NS_OK;