diff options
| author | Scott Mansell <phiren@gmail.com> | 2015-10-09 12:18:34 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-10-09 12:18:34 +1300 |
| commit | dd5df05c01aa221ac73a2d2aba44d87ccb095ca9 (patch) | |
| tree | f84e6453e8eb0a3e721f9076794c36fc929ebdaf /Source/Core | |
| parent | 400a737ef95dc5d8441d5a70850c558bf7b3f302 (diff) | |
| parent | 71d7cd6b9df86cae9c3507063ec39acfaffa7394 (diff) | |
Merge pull request #3148 from phire/logWindow_lockup
DolphinWX: Make UpdateLog() return in a finite time (aka, fix stack overflow messages when logging is enabled)
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinWX/LogWindow.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/Core/DolphinWX/LogWindow.cpp b/Source/Core/DolphinWX/LogWindow.cpp index 21ed3c303b..6dd6b10572 100644 --- a/Source/Core/DolphinWX/LogWindow.cpp +++ b/Source/Core/DolphinWX/LogWindow.cpp @@ -31,6 +31,8 @@ // Milliseconds between msgQueue flushes to wxTextCtrl #define UPDATETIME 200 +// Max size of msgQueue, old messages will be discarded when there are too many. +#define MSGQUEUE_MAX_SIZE 100 CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) @@ -279,7 +281,11 @@ void CLogWindow::UpdateLog() m_LogTimer.Stop(); - while (true) + // This function runs on the main gui thread, and needs to finish in a finite time otherwise + // the GUI will lock up, which could be an issue if new messages are flooding in faster than + // this function can render them to the screen. + // So we limit this function to processing MSGQUEUE_MAX_SIZE messages each time it's called. + for (int num = 0; num < MSGQUEUE_MAX_SIZE; num++) { u8 log_level; wxString log_msg; @@ -339,7 +345,7 @@ void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text) { std::lock_guard<std::mutex> lk(m_LogSection); - if (msgQueue.size() >= 100) + if (msgQueue.size() >= MSGQUEUE_MAX_SIZE) msgQueue.pop(); msgQueue.push(std::make_pair(u8(level), StrToWxStr(text))); |
