You're right. I noticed this while testing my mod based (which is still under development) yesterday and visited here to wrote this and my second iteration for the solution.
Actually the root cause of the problem is the usage of "CDownloadListCtrl::ChangeCategory" for two different purpose in the eMule source code.
1- Changing category as the name suggest.
2- Updating Download List Control items to refresh the list.
IMHO the good solution is to split this into "CDownloadListCtrl::ChangeCategory" and something like "CDownloadListCtrl::RefreshDownloadList"
But since I'm trying to keep the code delta of my mod as minimum as possible, I changed the code as below. This solves above mentioned problem while keeping fast category optimization mentioned in my first message:
DownloadListCtrl.cpp
void CDownloadListCtrl::ChangeCategory(int newsel)
// BuyukBang <-- Optimization: Faster Category Switch
{
SetRedraw(FALSE);
// BuyukBang --> Optimization: Faster Category Switch
if (curTab != newsel) {
// remove all displayed files and show the files in the selected category
DeleteAllItems();
for (ListItems::const_iterator it = m_ListItems.begin(); it != m_ListItems.end(); ++it) {
const CtrlItem_Struct* cur_item = it->second;
if (cur_item->type == FILE_TYPE) {
CPartFile* file = static_cast<CPartFile*>(cur_item->value);
if (file->CheckShowItemInGivenCat(newsel))
ShowFile(file);
}
}
} else {
// BuyukBang <-- Optimization: Faster Category Switch
// remove all displayed files with a different cat and show the correct ones
for (ListItems::const_iterator it = m_ListItems.begin(); it != m_ListItems.end(); ++it) {
const CtrlItem_Struct* cur_item = it->second;
if (cur_item->type == FILE_TYPE) {
CPartFile* file = static_cast<CPartFile*>(cur_item->value);
if (!file->CheckShowItemInGivenCat(newsel))
HideFile(file);
else
ShowFile(file);
}
}
} // BuyukBang <-- Optimization: Faster Category Switch
SetRedraw(TRUE);
curTab = newsel;
ShowFilesCount();
}
This post has been edited by BuyukBang: 03 September 2023 - 02:24 PM