1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix assertion failure on exit due to mutex lock

This commit is contained in:
Ivan Savenko 2023-07-24 23:01:44 +03:00
parent e23166df88
commit f827571f9b
2 changed files with 14 additions and 3 deletions

View File

@ -70,13 +70,22 @@ void InputHandler::handleCurrentEvent(const SDL_Event & current)
}
}
void InputHandler::processEvents()
std::vector<SDL_Event> InputHandler::acquireEvents()
{
boost::unique_lock<boost::mutex> lock(eventsMutex);
for(const auto & currentEvent : eventsQueue)
std::vector<SDL_Event> result;
std::swap(result, eventsQueue);
return result;
}
void InputHandler::processEvents()
{
std::vector<SDL_Event> eventsToProcess = acquireEvents();
for(const auto & currentEvent : eventsToProcess)
handleCurrentEvent(currentEvent);
eventsQueue.clear();
fingerHandler->handleUpdate();
}

View File

@ -29,6 +29,8 @@ class InputHandler
Point cursorPosition;
std::vector<SDL_Event> acquireEvents();
void preprocessEvent(const SDL_Event & event);
void handleCurrentEvent(const SDL_Event & current);
void handleUserEvent(const SDL_UserEvent & current);