summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2023-03-14 02:41:36 +0100
committerGitHub <noreply@github.com>2023-03-14 02:41:36 +0100
commit3783bedc250002adf4dc17ed3fc0d3191bf1e48c (patch)
treefa07ff86a44d17eff599f949628da5ac576c1d57 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
parent970ddf0ea0158d3f759050599e9f26e313e87aec (diff)
parentd6a8e6caaf1edfec74f3c41518cfb8e095f36bdc (diff)
Merge pull request #11635 from Dentomologist/wiimote_fix_disconnection_deadlock
ControllerInterface: Fix deadlock when Wii Remote disconnects
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 8f58525f0c..5b7e27ffe1 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -372,6 +372,14 @@ void ControllerInterface::UpdateInput()
// TODO: if we are an emulation input channel, we should probably always lock
// Prefer outdated values over blocking UI or CPU thread (avoids short but noticeable frame drop)
+
+ // Lock this first to avoid deadlock with m_devices_mutex in certain cases (such as a Wii Remote
+ // getting disconnected)
+ if (!m_devices_population_mutex.try_lock())
+ return;
+
+ std::lock_guard population_lock(m_devices_population_mutex, std::adopt_lock);
+
if (!m_devices_mutex.try_lock())
return;