mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 23:38:49 +00:00
ControllerInterface: add mutex around callbacks vector
This commit is contained in:
parent
1ed7532af8
commit
fd7cbd633e
2 changed files with 6 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
|
@ -232,6 +232,7 @@ void ControllerInterface::UpdateInput()
|
|||
//
|
||||
void ControllerInterface::RegisterDevicesChangedCallback(std::function<void()> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbacks_mutex);
|
||||
m_devices_changed_callbacks.emplace_back(std::move(callback));
|
||||
}
|
||||
|
||||
|
@ -242,6 +243,7 @@ void ControllerInterface::RegisterDevicesChangedCallback(std::function<void()> c
|
|||
//
|
||||
void ControllerInterface::InvokeDevicesChangedCallbacks() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_callbacks_mutex);
|
||||
for (const auto& callback : m_devices_changed_callbacks)
|
||||
callback();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue