Mgr: Clear our internal Internet cache when selecting a different computer; when removing entries from hash table, delete data to avoid memory leaks

This commit is contained in:
Charlie Fenton 2012-12-21 03:21:15 -08:00 committed by Oliver Bock
parent a78f458ca2
commit d95bf6945a
5 changed files with 25 additions and 2 deletions

View File

@ -7833,6 +7833,10 @@ Rom 20 Dec 2012
Charlie 21 Dec 2012
- Mgr: If network activity is suspended, don't retrieve URL references within
notices unless they are already in our cache or in the Windows cache.
- Mgr: Clear our internal Internet cache when selecting a different computer;
when removing entries from hash table, delete data to avoid memory leaks.
clientgui/
BOINCInternetFSHandler.cpp
BOINCInternetFSHandler.cpp,.h
NoticeListCtrl.cpp
ViewNotices.cpp

View File

@ -626,17 +626,32 @@ void CBOINCInternetFSHandler::UnchacheMissingItems() {
m_Hash->BeginFind();
wxHashTable::Node* node = m_Hash->Next();
for(;;) {
if (node == NULL) return;
if (node == NULL) return; // End of cache
MemFSHashObj* obj = (MemFSHashObj*)node->GetData();
// We must get next node before deleting this one
node = m_Hash->Next();
if (obj->m_Len == 0) {
delete obj;
m_Hash->Delete(obj->m_Key);
}
}
}
void CBOINCInternetFSHandler::ClearCache() {
m_Hash->BeginFind();
wxHashTable::Node* node = m_Hash->Next();
for(;;) {
if (node == NULL) return; // End of cache
MemFSHashObj* obj = (MemFSHashObj*)node->GetData();
// We must get next node before deleting this one
node = m_Hash->Next();
delete obj;
m_Hash->Delete(obj->m_Key);
}
}
void CBOINCInternetFSHandler::ShutDown() {
b_ShuttingDown = true;
#ifdef __WXMSW__

View File

@ -31,6 +31,7 @@ public:
virtual bool CanOpen(const wxString& strLocation);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& strLocation);
void UnchacheMissingItems();
void ClearCache();
void ShutDown();
protected:

View File

@ -542,6 +542,7 @@ void CNoticeListCtrl::Clear() {
SetItemCount(0);
m_bComputerChanged = true;
UpdateUI();
Refresh();
}

View File

@ -141,6 +141,8 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
strLastMachineName = strNewMachineName;
m_FetchingNoticesText->Show();
m_NoNoticesText->Hide();
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
((CBOINCInternetFSHandler*)internetFSHandler)->ClearCache();
m_pHtmlListPane->Clear();
}
}