Fix deadlock with KHR_debug.
An KHR_debug callback could end up waiting for a mutex on a thread which calls windows system functions. While this is not expressly forbidden by the standards, it does forbid directy calling windows system functions from a KHR_debug callback. Close enough.
This commit is contained in:
parent
067d65bbf5
commit
b9b80191d5
|
@ -279,10 +279,24 @@ void CLogWindow::UpdateLog()
|
||||||
|
|
||||||
m_LogTimer.Stop();
|
m_LogTimer.Stop();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_LogSection);
|
while (true)
|
||||||
while (!msgQueue.empty())
|
|
||||||
{
|
{
|
||||||
switch (msgQueue.front().first)
|
u8 log_level;
|
||||||
|
wxString log_msg;
|
||||||
|
|
||||||
|
// We can't hold this mutex while calling Wx functions, due to deadlocks
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
||||||
|
|
||||||
|
if (msgQueue.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
log_level = msgQueue.front().first;
|
||||||
|
log_msg = std::move(msgQueue.front().second);
|
||||||
|
msgQueue.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (log_level)
|
||||||
{
|
{
|
||||||
case LogTypes::LOG_LEVELS::LERROR:
|
case LogTypes::LOG_LEVELS::LERROR:
|
||||||
m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
|
m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
|
||||||
|
@ -309,15 +323,13 @@ void CLogWindow::UpdateLog()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgQueue.front().second.size())
|
if (log_msg.size())
|
||||||
{
|
{
|
||||||
int i = m_Log->GetLastPosition();
|
int i = m_Log->GetLastPosition();
|
||||||
m_Log->AppendText(msgQueue.front().second);
|
m_Log->AppendText(log_msg);
|
||||||
// White timestamp
|
// White timestamp
|
||||||
m_Log->SetStyle(i, i + 9, wxTextAttr(*wxWHITE));
|
m_Log->SetStyle(i, i + 9, wxTextAttr(*wxWHITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
msgQueue.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LogTimer.Start();
|
m_LogTimer.Start();
|
||||||
|
|
Loading…
Reference in New Issue