Bug 1354809 - Fix crash in nsMsgGroupView::LoadMessageByViewIndex(), take 2. r=jorgk
authoralta88 <alta88>
Fri, 22 Sep 2017 07:04:00 +0200
changeset 29027 2a13941913ba2a27ed98f02e750595c75b705969
parent 29026 6bc41c12fc0165a4a91eb8ce9dbebe988377c670
child 29028 988c15280e481afa0df0281a4bb006a3d5955010
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1354809
Bug 1354809 - Fix crash in nsMsgGroupView::LoadMessageByViewIndex(), take 2. r=jorgk
mailnews/base/src/nsMsgGroupView.cpp
mailnews/base/src/nsMsgGroupView.h
--- a/mailnews/base/src/nsMsgGroupView.cpp
+++ b/mailnews/base/src/nsMsgGroupView.cpp
@@ -1025,16 +1025,19 @@ nsMsgGroupView::CellTextForColumn(int32_
     return NS_OK;
   }
   return nsMsgDBView::CellTextForColumn(aRow, aColumnName, aValue);
 }
 
 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,
     // we should clear the message pane.
     nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
     nsCOMPtr <nsIMsgWindowCommands> windowCommands;
     if (msgWindow &&
         NS_SUCCEEDED(msgWindow->GetWindowCommands(getter_AddRefs(windowCommands))) &&
@@ -1080,32 +1083,16 @@ nsMsgGroupView::FindLevelInThread(nsIMsg
                                   nsMsgViewIndex viewIndex)
 {
   if (!(m_viewFlags & nsMsgViewFlagsType::kGroupBySort))
     return nsMsgDBView::FindLevelInThread(msgHdr, startOfThread, viewIndex);
 
   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()
 {
   // Return true to always use a header row as root grouped parent row.
   return true;
 }
 
 NS_IMETHODIMP
--- a/mailnews/base/src/nsMsgGroupView.h
+++ b/mailnews/base/src/nsMsgGroupView.h
@@ -47,20 +47,16 @@ public:
 
 protected:
   virtual void InternalClose();
   nsMsgGroupThread *AddHdrToThread(nsIMsgDBHdr *msgHdr, bool *pNewThread);
   virtual nsresult HashHdr(nsIMsgDBHdr *msgHdr, nsString& aHashKey);
   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();
   nsresult RebuildView(nsMsgViewFlagsTypeValue viewFlags);
   virtual nsMsgGroupThread *CreateGroupThread(nsIMsgDatabase *db);
 
   nsInterfaceHashtable <nsStringHashKey, nsIMsgThread> m_groupsTable;
   PRExplodedTime m_lastCurExplodedTime;
@@ -71,9 +67,8 @@ private:
   nsString m_kYesterdayString;
   nsString m_kLastWeekString;
   nsString m_kTwoWeeksAgoString;
   nsString m_kOldMailString;
   nsString m_kFutureDateString;
 };
 
 #endif
-