зеркало из https://github.com/mozilla/pjs.git
78280 The reason it was broken was because m_hdrs was not being built after sorting.
No need for m_hdrs because we already have m_keys and can fetch the hdrs. m_keys and m_folders are rebuilt on a sort operation. 75761 The problem is with first message for local folders because they have m_messageKey as 0 and we were caching msg headers. This was causing problems for search window because results are from multiple folders. fix suggested by david. r=gayatrib sr=bienvenu
This commit is contained in:
Родитель
43b71e1c46
Коммит
2027068ca2
|
@ -669,17 +669,7 @@ NS_IMETHODIMP nsMsgDBView::GetCellProperties(PRInt32 aRow, const PRUnichar *colI
|
|||
nsCOMPtr <nsIMsgDBHdr> msgHdr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (key == m_cachedMsgKey)
|
||||
msgHdr = m_cachedHdr;
|
||||
else
|
||||
{
|
||||
rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
m_cachedHdr = msgHdr;
|
||||
m_cachedMsgKey = key;
|
||||
}
|
||||
}
|
||||
rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
|
||||
|
||||
if (NS_FAILED(rv) || !msgHdr) {
|
||||
ClearHdrCache();
|
||||
|
@ -858,11 +848,25 @@ NS_IMETHODIMP nsMsgDBView::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
// search view will override this since headers can span db's
|
||||
nsresult nsMsgDBView::GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDBHdr **msgHdr)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsMsgKey key = m_keys.GetAt(index);
|
||||
if (key == nsMsgKey_None || !m_db)
|
||||
return NS_MSG_INVALID_DBVIEW_INDEX;
|
||||
|
||||
if (key == m_cachedMsgKey)
|
||||
*msgHdr = m_cachedHdr;
|
||||
else
|
||||
{
|
||||
rv = m_db->GetMsgHdrForKey(key, msgHdr);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
m_cachedHdr = *msgHdr;
|
||||
m_cachedMsgKey = key;
|
||||
}
|
||||
}
|
||||
NS_IF_ADDREF(*msgHdr);
|
||||
|
||||
return m_db->GetMsgHdrForKey(key, msgHdr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgDBView::GetFolderForViewIndex(nsMsgViewIndex index, nsIMsgFolder **aFolder)
|
||||
|
@ -888,18 +892,8 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
|
|||
|
||||
nsMsgKey key = m_keys.GetAt(aRow);
|
||||
nsCOMPtr <nsIMsgDBHdr> msgHdr;
|
||||
if (key == m_cachedMsgKey)
|
||||
msgHdr = m_cachedHdr;
|
||||
else
|
||||
{
|
||||
rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
m_cachedHdr = msgHdr;
|
||||
m_cachedMsgKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
|
||||
|
||||
if (NS_FAILED(rv) || !msgHdr) {
|
||||
ClearHdrCache();
|
||||
return NS_MSG_INVALID_DBVIEW_INDEX;
|
||||
|
|
|
@ -60,9 +60,6 @@ NS_IMETHODIMP nsMsgSearchDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeVal
|
|||
m_folders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
m_hdrs = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
m_dbToUseList = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -160,7 +157,6 @@ nsMsgSearchDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder)
|
|||
m_folders->AppendElement(supports);
|
||||
nsMsgKey msgKey;
|
||||
PRUint32 msgFlags;
|
||||
m_hdrs->AppendElement(aMsgHdr);
|
||||
aMsgHdr->GetMessageKey(&msgKey);
|
||||
aMsgHdr->GetFlags(&msgFlags);
|
||||
m_keys.Add(msgKey);
|
||||
|
@ -192,7 +188,6 @@ nsMsgSearchDBView::OnNewSearch()
|
|||
m_keys.RemoveAll();
|
||||
m_levels.RemoveAll();
|
||||
m_flags.RemoveAll();
|
||||
m_hdrs->Clear();
|
||||
|
||||
// mSearchResults->Clear();
|
||||
return NS_OK;
|
||||
|
@ -230,7 +225,6 @@ nsresult nsMsgSearchDBView::RemoveByIndex(nsMsgViewIndex index)
|
|||
return NS_MSG_INVALID_DBVIEW_INDEX;
|
||||
|
||||
m_folders->RemoveElementAt(index);
|
||||
m_hdrs->RemoveElementAt(index);
|
||||
|
||||
return nsMsgDBView::RemoveByIndex(index);
|
||||
}
|
||||
|
@ -331,7 +325,10 @@ nsMsgSearchDBView::InitializeGlobalsForDeleteAndFile(nsMsgViewIndex *indices, PR
|
|||
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(folderSupports, &rv);
|
||||
if (NS_SUCCEEDED(rv) && msgFolder && msgFolder == curFolder)
|
||||
{
|
||||
nsCOMPtr <nsISupports> hdrSupports = getter_AddRefs(m_hdrs->ElementAt(indices[i]));
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv = GetMsgHdrForViewIndex(indices[i],getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
nsCOMPtr <nsISupports> hdrSupports = do_QueryInterface(msgHdr);
|
||||
msgHdrsForOneFolder->AppendElement(hdrSupports);
|
||||
}
|
||||
}
|
||||
|
@ -469,3 +466,4 @@ NS_IMETHODIMP nsMsgSearchDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgView
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ protected:
|
|||
nsresult GroupSearchResultsByFolder();
|
||||
|
||||
nsCOMPtr <nsISupportsArray> m_folders; // maybe we should store ranges, or the actual headers instead.
|
||||
nsCOMPtr <nsISupportsArray> m_hdrs;
|
||||
nsCOMPtr <nsISupportsArray> m_hdrsForEachFolder;
|
||||
nsCOMPtr <nsISupportsArray> m_copyListenerList;
|
||||
nsCOMPtr <nsISupportsArray> m_uniqueFolders;
|
||||
|
|
Загрузка…
Ссылка в новой задаче