summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2014-03-23 00:29:08 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2014-03-23 00:29:08 -0500
commit5dabe598a40bc9f0975151bdb94ffaac938dd899 (patch)
tree5443be47cac87750fc655cecb1e08c9468cdd1a1 /Source/Core
parentbf5f485a2c97cf38a9cbaa0677af850838de397f (diff)
parent5edce0eeb695e1bd9f5de863d7b86797f69bd38e (diff)
Merge pull request #180 from lioncash/log-window-cleanup
Small log queue clearing simplification.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinWX/LogWindow.cpp89
1 files changed, 43 insertions, 46 deletions
diff --git a/Source/Core/DolphinWX/LogWindow.cpp b/Source/Core/DolphinWX/LogWindow.cpp
index c9c65d0fc9..84413c9996 100644
--- a/Source/Core/DolphinWX/LogWindow.cpp
+++ b/Source/Core/DolphinWX/LogWindow.cpp
@@ -205,8 +205,7 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
{
std::lock_guard<std::mutex> lk(m_LogSection);
- int msgQueueSize = (int)msgQueue.size();
- for (int i = 0; i < msgQueueSize; i++)
+ while (!msgQueue.empty())
msgQueue.pop();
}
@@ -280,10 +279,11 @@ void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
{
- if (!m_LogAccess) return;
- if (m_ignoreLogTimer) return;
+ if (!m_LogAccess || m_ignoreLogTimer)
+ return;
UpdateLog();
+
// Scroll to the last line
if (!msgQueue.empty())
{
@@ -294,58 +294,55 @@ void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
void CLogWindow::UpdateLog()
{
- if (!m_LogAccess) return;
- if (!m_Log) return;
+ if (!m_LogAccess || !m_Log)
+ return;
// m_LogTimer->Stop();
// instead of stopping the timer, let's simply ignore its calls during UpdateLog,
// because repeatedly stopping and starting a timer churns memory (and potentially leaks it).
m_ignoreLogTimer = true;
- if (!msgQueue.empty())
+ std::lock_guard<std::mutex> lk(m_LogSection);
+ while (!msgQueue.empty())
{
- std::lock_guard<std::mutex> lk(m_LogSection);
- int msgQueueSize = (int)msgQueue.size();
- for (int i = 0; i < msgQueueSize; i++)
+ switch (msgQueue.front().first)
+ {
+ case ERROR_LEVEL:
+ m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
+ break;
+
+ case WARNING_LEVEL:
+ m_Log->SetDefaultStyle(wxTextAttr(wxColour(255, 255, 0))); // YELLOW
+ break;
+
+ case NOTICE_LEVEL:
+ m_Log->SetDefaultStyle(wxTextAttr(*wxGREEN));
+ break;
+
+ case INFO_LEVEL:
+ m_Log->SetDefaultStyle(wxTextAttr(*wxCYAN));
+ break;
+
+ case DEBUG_LEVEL:
+ m_Log->SetDefaultStyle(wxTextAttr(*wxLIGHT_GREY));
+ break;
+
+ default:
+ m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
+ break;
+ }
+
+ if (msgQueue.front().second.size())
{
- switch (msgQueue.front().first)
- {
- case ERROR_LEVEL:
- m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
- break;
-
- case WARNING_LEVEL:
- m_Log->SetDefaultStyle(wxTextAttr(wxColour(255, 255, 0))); // YELLOW
- break;
-
- case NOTICE_LEVEL:
- m_Log->SetDefaultStyle(wxTextAttr(*wxGREEN));
- break;
-
- case INFO_LEVEL:
- m_Log->SetDefaultStyle(wxTextAttr(*wxCYAN));
- break;
-
- case DEBUG_LEVEL:
- m_Log->SetDefaultStyle(wxTextAttr(*wxLIGHT_GREY));
- break;
-
- default:
- m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
- break;
- }
- if (msgQueue.front().second.size())
- {
- int j = m_Log->GetLastPosition();
- m_Log->AppendText(msgQueue.front().second);
- // White timestamp
- m_Log->SetStyle(j, j + 9, wxTextAttr(*wxWHITE));
- }
- msgQueue.pop();
+ int i = m_Log->GetLastPosition();
+ m_Log->AppendText(msgQueue.front().second);
+ // White timestamp
+ m_Log->SetStyle(i, i + 9, wxTextAttr(*wxWHITE));
}
- } // unlock log
- // m_LogTimer->Start(UPDATETIME);
+ msgQueue.pop();
+ }
+
m_ignoreLogTimer = false;
}