From 91aa0c12175f33a4184ccaf41181b0a799f7cc55 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Tue, 28 May 2024 17:13:00 +0300 Subject: [PATCH] Fix operation order --- src/logid/backend/hidpp10/ReceiverMonitor.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/logid/backend/hidpp10/ReceiverMonitor.cpp b/src/logid/backend/hidpp10/ReceiverMonitor.cpp index 026f296c..44ecd32e 100644 --- a/src/logid/backend/hidpp10/ReceiverMonitor.cpp +++ b/src/logid/backend/hidpp10/ReceiverMonitor.cpp @@ -158,7 +158,6 @@ void ReceiverMonitor::enumerate() { } void ReceiverMonitor::waitForDevice(hidpp::DeviceIndex index) { - const std::lock_guard lock(_wait_mutex); if (!_waiters.count(index)) { _waiters.emplace(index, _receiver->rawDevice()->addEventHandler( {[index](const std::vector& report) -> bool { @@ -219,9 +218,8 @@ void ReceiverMonitor::_stopPair() { void ReceiverMonitor::_addHandler(const hidpp::DeviceConnectionEvent& event, int tries) { auto device_path = _receiver->devicePath(); try { - addDevice(event); - const std::lock_guard lock(_wait_mutex); _waiters.erase(event.index); + addDevice(event); } catch (DeviceNotReady& e) { if (tries == max_tries) { logPrintf(WARN, "Failed to add device %s:%d after %d tries."