From 8b19b98722803728c3d3ecc3b88f01dfb7cb63fb Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Sat, 7 Apr 2001 05:44:11 +0000 Subject: [PATCH] fix for #74930. Go | Next | Message crashes on an empty view. sr=bienvenu --- mailnews/base/src/nsMsgDBView.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 3dccb56f61fd..0770eba0ab25 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -3430,7 +3430,7 @@ nsresult nsMsgDBView::MarkThreadRead(nsIMsgThread *threadHdr, nsMsgViewIndex thr // Starting from startIndex, performs the passed in navigation, including // any marking read needed, and returns the resultId and resultIndex of the -// destination of the navigation. If there are no more unread in the view, +// destination of the navigation. If no message is found in the view, // it returns a resultId of nsMsgKey_None and an resultIndex of nsMsgViewIndex_None. NS_IMETHODIMP nsMsgDBView::ViewNavigate(nsMsgNavigationTypeValue motion, nsMsgKey *pResultKey, nsMsgViewIndex *pResultIndex, nsMsgViewIndex *pThreadIndex, PRBool wrap) { @@ -3462,16 +3462,17 @@ nsresult nsMsgDBView::NavigateFromPos(nsMsgNavigationTypeValue motion, nsMsgView nsMsgViewIndex lastIndex = (GetSize() > 0) ? (nsMsgViewIndex) GetSize() - 1 : nsMsgViewIndex_None; nsMsgViewIndex threadIndex = nsMsgViewIndex_None; + // if there aren't any messages in the view, bail out. + if (GetSize() <= 0) { + *pResultIndex = nsMsgViewIndex_None; + *pResultKey = nsMsgKey_None; + return NS_OK; + } + switch (motion) { case nsMsgNavigationType::firstMessage: - if (GetSize() > 0) { - *pResultIndex = 0; - *pResultKey = m_keys.GetAt(0); - } - else { - *pResultIndex = nsMsgViewIndex_None; - *pResultKey = nsMsgKey_None; - } + *pResultIndex = 0; + *pResultKey = m_keys.GetAt(0); break; case nsMsgNavigationType::nextMessage: // return same index and id on next on last message