diff options
| author | Michael M <mchtly@gmail.com> | 2017-11-10 12:29:25 -0800 |
|---|---|---|
| committer | Michael M <mchtly@gmail.com> | 2017-11-10 13:37:42 -0800 |
| commit | fd7cbd633edbac9e38592b9253a507410d7d6553 (patch) | |
| tree | 8de0ebe9dc0f51f95a19db9702014df7eda85a66 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | |
| parent | 1ed7532af850691eea8d7eee502f59ed20a37694 (diff) | |
ControllerInterface: add mutex around callbacks vector
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 1552cd7dc2..9e3c7ba7af 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -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(); } |
