Commit 0cbbfc68 authored by Charlie Fenton's avatar Charlie Fenton Committed by Oliver Bock

Mgr: When closing Simple View notices, wait for all Async Internet access to...

Mgr: When closing Simple View notices, wait for all Async Internet access to complete before calling the notices panel destructor
parent f0254407
......@@ -7897,3 +7897,13 @@ David 24 Dec 2012
client/
work_fetch.cpp
Charlie 26 Dec 2012
- Mgr: When closing Simple View notices, wait for all Async Internet access
to complete before calling the notices panel destructor.
clientgui/
BOINCBaseFrame.cpp
BOINCInternetFSHandler.cpp,.h
NoticeListCtrl.cpp
sg_DlgMessages.cpp,.h
......@@ -360,7 +360,7 @@ void CBOINCBaseFrame::OnExit(wxCommandEvent& WXUNUSED(event)) {
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->ShutDown();
((CBOINCInternetFSHandler*)internetFSHandler)->SetAbortInternetIO();
}
// Save state before exiting
......
......@@ -619,7 +619,7 @@ void CBOINCInternetFSHandler::ClearCache() {
}
void CBOINCInternetFSHandler::ShutDown(bool set) {
void CBOINCInternetFSHandler::SetAbortInternetIO(bool set) {
b_ShuttingDown = set;
#ifdef __WXMSW__
if (m_InputStream) {
......
......@@ -33,7 +33,7 @@ public:
bool ItemsFailedToLoad() { return m_bMissingItems; }
void UnchacheMissingItems();
void ClearCache();
void ShutDown(bool set = true);
void SetAbortInternetIO(bool set = true);
protected:
static bool CheckHash(const wxString& strLocation);
......
......@@ -377,6 +377,11 @@ CNoticeListCtrl::CNoticeListCtrl( )
CNoticeListCtrl::CNoticeListCtrl( wxWindow* parent )
{
Create( parent );
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->SetAbortInternetIO(false);
}
}
......@@ -390,7 +395,7 @@ CNoticeListCtrl::~CNoticeListCtrl( )
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->ShutDown(false);
((CBOINCInternetFSHandler*)internetFSHandler)->SetAbortInternetIO(false);
}
}
......
......@@ -94,6 +94,7 @@ bool CPanelMessages::Create()
{
////@begin CPanelMessages member initialisation
m_bProcessingRefreshEvent = false;
m_bWaitingToClose = false;
////@end CPanelMessages member initialisation
CreateControls();
......@@ -251,6 +252,8 @@ void CPanelMessages::OnEraseBackground(wxEraseEvent& event){
*/
void CPanelMessages::OnRefresh() {
if (m_bWaitingToClose) return;
if (!m_bProcessingRefreshEvent) {
m_bProcessingRefreshEvent = true;
......@@ -285,16 +288,21 @@ void CPanelMessages::OnRefresh() {
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
m_pHtmlListPane->UpdateUI();
bMissingItems = ((CBOINCInternetFSHandler*)internetFSHandler)->ItemsFailedToLoad();
if (bMissingItems != m_bMissingItems) {
m_ReloadNoticesPanel->Show(bMissingItems);
Layout();
m_bMissingItems = bMissingItems;
if (m_bWaitingToClose) {
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
GetEventHandler()->AddPendingEvent(evt);
} else {
bMissingItems = ((CBOINCInternetFSHandler*)internetFSHandler)->ItemsFailedToLoad();
if (bMissingItems != m_bMissingItems) {
m_ReloadNoticesPanel->Show(bMissingItems);
Layout();
m_bMissingItems = bMissingItems;
}
m_FetchingNoticesText->Show(m_pHtmlListPane->m_bDisplayFetchingNotices);
m_NoNoticesText->Show(m_pHtmlListPane->m_bDisplayEmptyNotice);
}
m_FetchingNoticesText->Show(m_pHtmlListPane->m_bDisplayFetchingNotices);
m_NoNoticesText->Show(m_pHtmlListPane->m_bDisplayEmptyNotice);
m_bProcessingRefreshEvent = false;
}
}
......@@ -308,9 +316,18 @@ void CPanelMessages::OnOK( wxCommandEvent& event ) {
// Shut down any asynchronous Internet access in progress
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->ShutDown();
((CBOINCInternetFSHandler*)internetFSHandler)->SetAbortInternetIO();
}
// If we were called during Yield() in async Internet I/O,
// it is not safe to call our destructor until OnRefresh()
// has returned from m_pHtmlListPane->UpdateUI(), so just
// set a flag to close this dialog at that time.
if (m_bProcessingRefreshEvent) {
m_bWaitingToClose = true;
return;
}
event.Skip();
}
......
......@@ -129,6 +129,7 @@ protected:
wxStaticText* m_FetchingNoticesText;
wxStaticText* m_NoNoticesText;
bool m_bMissingItems;
bool m_bWaitingToClose;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment