MGR: Separate refresh of Event Log from refresh of tabs; Update Notices tab only when data changed; Clean up some async RPC logic

svn path=/trunk/boinc/; revision=20110
This commit is contained in:
Charlie Fenton 2010-01-09 01:42:46 +00:00
parent 10a8041371
commit f8e7683427
11 changed files with 91 additions and 89 deletions

View File

@ -209,9 +209,22 @@ Rom 7 Jan 2010
clientgui/
ViewNotifications.cpp
Charlie 6 Jan 2010
Charlie 8 Jan 2010
- client: Fix another crash bug due to calling memset(this, 0, sizeof(*this))
when the data contains a std::string.
client/
cs_notice.cpp
Charlie 8 Jan 2010
- MGR: Separate refresh of Event Log from refresh of tabs.
- MGR: Update Notices tab only when data has changed.
- MGR: Clean up some async RPC logic.
clientgui/
AdvancedFrame.cpp
AsyncRPC.cpp, .h
DlgEventLog.cpp, .h
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp
ViewNotifications.cpp, .h

View File

@ -985,7 +985,6 @@ int CAdvancedFrame::_GetCurrentViewPage() {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
int vw_msg = wxGetApp().GetEventLog() ? VW_MSGS : 0;
wxASSERT(m_pNotebook);
@ -995,7 +994,7 @@ int CAdvancedFrame::_GetCurrentViewPage() {
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(pView);
return pView->GetViewCurrentViewPage() | vw_msg;
return pView->GetViewCurrentViewPage();
}
@ -1634,7 +1633,6 @@ void CAdvancedFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxTimerEvent timerEvent;
CDlgEventLog* eventLog;
wxASSERT(m_pNotebook);
@ -1645,11 +1643,6 @@ void CAdvancedFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
wxASSERT(pView);
pView->FireOnListRender(timerEvent);
eventLog = wxGetApp().GetEventLog();
if (eventLog) {
eventLog->OnRefresh(timerEvent);
}
}
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshView - Function End"));

View File

@ -32,6 +32,7 @@
#include "BOINCTaskBar.h"
#include "error_numbers.h"
#include "SkinManager.h"
#include "DlgEventLog.h"
#include "util.h"
extern bool s_bSkipExitConfirmation;
@ -1140,9 +1141,11 @@ void CMainDocument::HandleCompletedRPC() {
}
#endif
// CachedMessageUpdate() does not do any RPCs, so it is safe here
if (current_rpc_request.rpcType == RPC_TYPE_ASYNC_WITH_UPDATE_MESSAGE_LIST_AFTER) {
CachedMessageUpdate();
if (current_rpc_request.rpcType == RPC_TYPE_ASYNC_WITH_REFRESH_EVENT_LOG_AFTER) {
CDlgEventLog* eventLog = wxGetApp().GetEventLog();
if (eventLog) {
eventLog->OnRefresh();
}
}
current_rpc_request.clear();

View File

@ -148,17 +148,13 @@ enum ASYNC_RPC_TYPE {
// Periodic RPC as above, but on completion also process a
// wxEVT_FRAME_REFRESHVIEW event to refresh the display.
RPC_TYPE_ASYNC_WITH_REFRESH_AFTER,
// Periodic RPC as above, but on completion also update message
// list by calling CMainDocument::CachedMessageUpdate().
RPC_TYPE_ASYNC_WITH_UPDATE_MESSAGE_LIST_AFTER,
// Periodic RPC as above, but on completion also update notice
// list by calling CMainDocument::CachedNoticeUpdate().
RPC_TYPE_ASYNC_WITH_UPDATE_NOTICES_LIST_AFTER,
// Periodic RPC as above, but on completion also process a
// wxEVT_FRAME_REFRESHVIEW event to refresh the display.
RPC_TYPE_ASYNC_WITH_REFRESH_EVENT_LOG_AFTER,
// Periodic RPC as above, but on completion also process a
// wxEVT_TASKBAR_REFRESH event to refresh the taskbar icon.
RPC_TYPE_ASYNC_WITH_UPDATE_TASKBAR_ICON_AFTER,
NUM_RPC_TYPES
};
// Pass the following structure to CMainDocument::RequestRPC()

View File

@ -295,10 +295,9 @@ void CDlgEventLog::OnClose(wxCloseEvent& WXUNUSED(event)) {
/*!
* called from CAdvancedFrame::OnRefreshView()
* called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
*/
void CDlgEventLog::OnRefresh( wxTimerEvent& WXUNUSED(event) ) {
void CDlgEventLog::OnRefresh() {
bool isConnected;
static bool was_connected = false;

View File

@ -103,8 +103,8 @@ public:
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SIMPLE_HELP
void OnButtonHelp( wxCommandEvent& event );
/// wxEVT_TIMER event handler for ID_DLGEVENTLOG
void OnRefresh( wxTimerEvent& event );
/// called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
void OnRefresh();
////@end CDlgEventLog event handler declarations
////@begin CDlgEventLog member function declarations

View File

@ -878,39 +878,40 @@ void CMainDocument::RunPeriodicRPCs() {
// *********** RPC_GET_NOTICES **************
request.clear();
request.which_rpc = RPC_GET_NOTICES;
// m_iMessageSequenceNumber could change between request and execution
// of RPC, so pass in a pointer rather than its value
request.arg1 = &m_iNoticeSequenceNumber;
request.arg2 = &notices;
request.rpcType = (currentTabView & VW_NOTIF) ?
RPC_TYPE_ASYNC_WITH_REFRESH_AFTER : RPC_TYPE_ASYNC_WITH_UPDATE_NOTICES_LIST_AFTER;
request.completionTime = NULL;
request.resultPtr = &m_iGet_notices_rpc_result;
RequestRPC(request);
if (currentTabView & VW_NOTIF) {
request.clear();
request.which_rpc = RPC_GET_NOTICES;
// m_iNoticeSequenceNumber could change between request and execution
// of RPC, so pass in a pointer rather than its value
request.arg1 = &m_iNoticeSequenceNumber;
request.arg2 = &notices;
request.rpcType = RPC_TYPE_ASYNC_WITH_REFRESH_AFTER;
request.completionTime = NULL;
request.resultPtr = &m_iGet_notices_rpc_result;
RequestRPC(request);
}
// *********** RPC_GET_MESSAGES **************
request.clear();
request.which_rpc = RPC_GET_MESSAGES;
// m_iMessageSequenceNumber could change between request and execution
// of RPC, so pass in a pointer rather than its value
request.arg1 = &m_iMessageSequenceNumber;
request.arg2 = &messages;
// request.arg2 = &async_messages_buf;
// request.exchangeBuf = &messages;
request.rpcType = (currentTabView & VW_MSGS) ?
RPC_TYPE_ASYNC_WITH_REFRESH_AFTER : RPC_TYPE_ASYNC_WITH_UPDATE_MESSAGE_LIST_AFTER;
request.completionTime = NULL;
request.resultPtr = &m_iGet_messages_rpc_result;
RequestRPC(request);
ts = dtNow - m_dtCachedStateTimestamp;
if (ts.GetSeconds() >= STATERPC_INTERVAL) {
if ((currentTabView & VW_SMSG) || wxGetApp().GetEventLog()) {
request.clear();
request.which_rpc = RPC_GET_MESSAGES;
// m_iMessageSequenceNumber could change between request and execution
// of RPC, so pass in a pointer rather than its value
request.arg1 = &m_iMessageSequenceNumber;
request.arg2 = &messages;
// request.arg2 = &async_messages_buf;
// request.exchangeBuf = &messages;
request.rpcType = RPC_TYPE_ASYNC_WITH_REFRESH_EVENT_LOG_AFTER;
request.completionTime = NULL;
request.resultPtr = &m_iGet_messages_rpc_result;
RequestRPC(request);
ts = dtNow - m_dtCachedStateTimestamp;
if (ts.GetSeconds() >= STATERPC_INTERVAL) {
}
// *********** RPC_GET_STATE **************
request.clear();

View File

@ -48,7 +48,6 @@ typedef struct {
#define VW_XFER 4
#define VW_STAT 8
#define VW_DISK 16
#define VW_MSGS 32
#define VW_NOTIF 128
#define VW_SGUI 256
#define VW_SMSG 2048

View File

@ -71,6 +71,8 @@ CViewNotifications::CViewNotifications(wxNotebook* pNotebook) :
Layout();
m_iOldNoticeCount = 0;
pGroup = new CTaskItemGroup( _("News Feeds") );
m_TaskGroups.push_back( pGroup );
@ -153,37 +155,40 @@ void CViewNotifications::OnListRender( wxTimerEvent& WXUNUSED(event) ) {
if (n == -1) {
strItems += _("Retrieving notices...");
} else {
// Update display only if there is something new
if (n != m_iOldNoticeCount) {
m_iOldNoticeCount = n;
// Pre-allocate buffer size so string concat is much faster
strItems.Alloc(4096*n);
// Pre-allocate buffer size so string concat is much faster
strItems.Alloc(4096*n);
for (i = 0; i < (unsigned int)n; i++) {
NOTICE* np = pDoc->notice(i);
if (!np) continue;
char tbuf[512];
if (strlen(np->title)) {
sprintf(tbuf, "<b>%s</b><br>", np->title);
strItems += wxString(tbuf, wxConvUTF8);
for (i = 0; i < (unsigned int)n; i++) {
NOTICE* np = pDoc->notice(i);
if (!np) continue;
char tbuf[512];
if (strlen(np->title)) {
sprintf(tbuf, "<b>%s</b><br>", np->title);
strItems += wxString(tbuf, wxConvUTF8);
}
strItems += wxString(np->description.c_str(), wxConvUTF8);
strItems += wxT("<br><font size=-2 color=#8f8f8f>");
dtBuffer.Set((time_t)np->arrival_time);
strItems += dtBuffer.Format();
strItems += wxT("</font><hr>\n");
}
strItems += wxString(np->description.c_str(), wxConvUTF8);
strItems += wxT("<br><font size=-2 color=#8f8f8f>");
dtBuffer.Set((time_t)np->arrival_time);
strItems += dtBuffer.Format();
strItems += wxT("</font><hr>\n");
strHTML = wxT("<html>\n<body>\n");
strHTML += strItems;
strHTML += wxT("<br><img src=http://boinc.berkeley.edu/logo/www_logo.gif>\n");
strHTML += wxT("</body>\n</html>\n");
m_pHtmlPane->SetFonts(wxT("Sans Serif"), wxT("Courier"), 0);
m_pHtmlPane->SetPage( strHTML );
}
}
strHTML = wxT("<html>\n<body>\n");
strHTML += strItems;
//strHTML += wxT("<br><img src=http://boinc.berkeley.edu/logo/www_logo.gif>\n");
strHTML += wxT("</body>\n</html>\n");
m_pHtmlPane->SetFonts(wxT("Sans Serif"), wxT("Courier"), 0);
m_pHtmlPane->SetPage( strHTML );
s_bInProgress = false;
}
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotifications::OnListRender - Function End"));
}

View File

@ -43,6 +43,7 @@ public:
protected:
wxHtmlWindow* m_pHtmlPane;
int m_iOldNoticeCount;
virtual bool OnSaveState( wxConfigBase* pConfig );
virtual bool OnRestoreState( wxConfigBase* pConfig );

View File

@ -251,12 +251,10 @@ bool CSimpleFrame::SaveState() {
int CSimpleFrame::_GetCurrentViewPage() {
int vw_msg = wxGetApp().GetEventLog() ? VW_MSGS : 0;
if (isMessagesDlgOpen()) {
return VW_SGUI | VW_SMSG | vw_msg;
return VW_SGUI | VW_SMSG;
} else {
return VW_SGUI | vw_msg;
return VW_SGUI;
}
return 0; // Should never happen.
}
@ -324,7 +322,6 @@ void CSimpleFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnRefreshView - Function Start"));
static bool bAlreadyRunning = false;
CDlgEventLog* eventLog;
wxTimerEvent timerEvent;
if (bAlreadyRunning) return;
@ -336,11 +333,6 @@ void CSimpleFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
dlgMsgsPtr->OnRefresh();
}
eventLog = wxGetApp().GetEventLog();
if (eventLog) {
eventLog->OnRefresh(timerEvent);
}
bAlreadyRunning = false;
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnRefreshView - Function End"));