From b8f412a8e55a23170960b11a8fd8892891035ab2 Mon Sep 17 00:00:00 2001 From: alta88 Date: Fri, 22 Sep 2017 07:04:00 +0200 Subject: [PATCH] Bug 1354809 - Fix crash in nsMsgGroupView::LoadMessageByViewIndex(), take 2. r=jorgk --- mailnews/base/src/nsMsgGroupView.cpp | 19 +++---------------- mailnews/base/src/nsMsgGroupView.h | 5 ----- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/mailnews/base/src/nsMsgGroupView.cpp b/mailnews/base/src/nsMsgGroupView.cpp index b73ea5bf30..215dc12ae5 100644 --- a/mailnews/base/src/nsMsgGroupView.cpp +++ b/mailnews/base/src/nsMsgGroupView.cpp @@ -1030,6 +1030,9 @@ nsMsgGroupView::CellTextForColumn(int32_t aRow, NS_IMETHODIMP nsMsgGroupView::LoadMessageByViewIndex(nsMsgViewIndex aViewIndex) { + if (!IsValidIndex(aViewIndex)) + return NS_MSG_INVALID_DBVIEW_INDEX; + if (m_flags[aViewIndex] & MSG_VIEW_FLAG_DUMMY) { // If we used to have one item selected, and now we have more than one, @@ -1085,22 +1088,6 @@ nsMsgGroupView::FindLevelInThread(nsIMsgDBHdr *msgHdr, return (startOfThread == viewIndex) ? 0 : 1; } - -nsMsgViewIndex -nsMsgGroupView::ThreadIndexOfMsg(nsMsgKey msgKey, - nsMsgViewIndex msgIndex /* = nsMsgViewIndex_None */, - int32_t *pThreadCount /* = NULL */, - uint32_t *pFlags /* = NULL */) -{ - if (msgIndex != nsMsgViewIndex_None && GroupViewUsesDummyRow()) - { - // This case is all we care about at this point. - if (m_flags[msgIndex] & MSG_VIEW_FLAG_ISTHREAD) - return msgIndex; - } - return nsMsgDBView::ThreadIndexOfMsg(msgKey, msgIndex, pThreadCount, pFlags); -} - bool nsMsgGroupView::GroupViewUsesDummyRow() { diff --git a/mailnews/base/src/nsMsgGroupView.h b/mailnews/base/src/nsMsgGroupView.h index e6a721d50a..026d9ac479 100644 --- a/mailnews/base/src/nsMsgGroupView.h +++ b/mailnews/base/src/nsMsgGroupView.h @@ -52,10 +52,6 @@ protected: nsresult GetAgeBucketValue(nsIMsgDBHdr *aMsgHdr, uint32_t * aAgeBucket, bool rcvDate = false); // helper function to get the age bucket for a hdr, useful when grouped by date nsresult OnNewHeader(nsIMsgDBHdr *newHdr, nsMsgKey aParentKey, bool /*ensureListed*/) override; virtual int32_t FindLevelInThread(nsIMsgDBHdr *msgHdr, nsMsgViewIndex startOfThread, nsMsgViewIndex viewIndex) override; - nsMsgViewIndex ThreadIndexOfMsg(nsMsgKey msgKey, - nsMsgViewIndex msgIndex = nsMsgViewIndex_None, - int32_t *pThreadCount = NULL, - uint32_t *pFlags = NULL) override; // Returns true if we are grouped by a sort attribute that uses a dummy row. bool GroupViewUsesDummyRow(); @@ -76,4 +72,3 @@ private: }; #endif -