Don't hold the lock when processing messages, only when taking them off the queue. Fixes #10383

This commit is contained in:
Henrik Rydgård 2017-12-10 11:28:27 +01:00
parent 36d61c3595
commit 27227f87fd

View file

@ -942,15 +942,18 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
void NativeUpdate() {
PROFILE_END_FRAME();
std::vector<PendingMessage> toProcess;
{
std::lock_guard<std::mutex> lock(pendingMutex);
for (size_t i = 0; i < pendingMessages.size(); i++) {
HandleGlobalMessage(pendingMessages[i].msg, pendingMessages[i].value);
screenManager->sendMessage(pendingMessages[i].msg.c_str(), pendingMessages[i].value.c_str());
}
toProcess = std::move(pendingMessages);
pendingMessages.clear();
}
for (size_t i = 0; i < toProcess.size(); i++) {
HandleGlobalMessage(toProcess[i].msg, toProcess[i].value);
screenManager->sendMessage(toProcess[i].msg.c_str(), toProcess[i].value.c_str());
}
g_DownloadManager.Update();
screenManager->update();
}