MGR: Limit event log to 2000 messages, deleting oldest if necessary

This commit is contained in:
Charlie Fenton 2013-02-15 06:41:30 -08:00 committed by Oliver Bock
parent 031dbae81b
commit e0dc22a52b
2 changed files with 7 additions and 11 deletions

View File

@ -139,6 +139,7 @@ bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& capt
m_iPreviousFirstMsgSeqNum = 0;
m_iPreviousLastMsgSeqNum = 0;
m_iNumDeletedFilteredRows = 0;
m_iTotalDeletedFilterRows = 0;
if (!s_bIsFiltered) {
s_strFilteredProjectName.clear();
@ -404,6 +405,7 @@ void CDlgEventLog::OnMessagesFilter( wxCommandEvent& WXUNUSED(event) ) {
m_iFilteredIndexes.Clear();
s_strFilteredProjectName.clear();
m_iTotalDeletedFilterRows = 0;
if (s_bIsFiltered) {
s_bIsFiltered = false;
@ -448,7 +450,6 @@ wxInt32 CDlgEventLog::GetFilteredMessageIndex( wxInt32 iRow) const {
// Get the (possibly filtered) item count (i.e., the Row count)
wxInt32 CDlgEventLog::GetDocCount() {
int i, j, numDeletedRows;
MESSAGE* message;
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
@ -471,6 +472,7 @@ wxInt32 CDlgEventLog::GetDocCount() {
if (m_iFilteredIndexes[0] >= numDeletedRows) break;
m_iFilteredIndexes.RemoveAt(0);
m_iNumDeletedFilteredRows++;
m_iTotalDeletedFilterRows++;
}
// Adjust the remaining indexes
@ -482,22 +484,15 @@ wxInt32 CDlgEventLog::GetDocCount() {
// Add indexes of new messages to filtered list as appropriate
i = m_iTotalDocCount - (pDoc->GetLastMsgSeqNum() - m_iPreviousLastMsgSeqNum);
for (; i < m_iTotalDocCount; i++) {
message = pDoc->message(i);
MESSAGE* message = pDoc->message(i);
if (message->project.empty() || (message->project == s_strFilteredProjectName)) {
m_iFilteredIndexes.Add(i);
}
}
m_iFilteredDocCount = (int)(m_iFilteredIndexes.GetCount());
message = pDoc->message(m_iFilteredIndexes[0]);
if (message) {
m_iFirstFilteredSeqNum = message->seqno;
} else {
m_iFirstFilteredSeqNum = 0;
}
} else {
m_iFilteredDocCount = m_iTotalDocCount;
m_iNumDeletedFilteredRows = numDeletedRows;
m_iFirstFilteredSeqNum = pDoc->GetFirstMsgSeqNum();
}
if (numDeletedRows > 0) {
@ -861,6 +856,7 @@ void CDlgEventLog::ResetMessageFiltering() {
s_strFilteredProjectName.clear();
m_iFilteredIndexes.Clear();
SetFilterButtonText();
m_iTotalDeletedFilterRows = 0;
}
@ -916,7 +912,7 @@ wxListItemAttr* CDlgEventLog::OnListGetItemAttr(long item) const {
if (wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) != wxColor(wxT("WHITE"))) return NULL;
if (message) {
item += m_iFirstFilteredSeqNum;
item += s_bIsFiltered ? m_iTotalDeletedFilterRows : m_iPreviousFirstMsgSeqNum;
switch(message->priority) {
case MSG_USER_ALERT:
pAttribute = item % 2 ? m_pMessageErrorGrayAttr : m_pMessageErrorAttr;

View File

@ -151,7 +151,7 @@ private:
wxInt32 m_iPreviousFirstMsgSeqNum;
wxInt32 m_iPreviousLastMsgSeqNum;
wxInt32 m_iNumDeletedFilteredRows;
wxInt32 m_iFirstFilteredSeqNum;
wxInt32 m_iTotalDeletedFilterRows;
wxInt32 m_iPreviousRowCount;
wxButton* m_pFilterButton;