From 683d2ac95bf4d92e9de0a50e151bb0449c095245 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 16 May 2024 14:48:04 +1200 Subject: [PATCH] gimbal: prevent segfault without gimbal v2 forced It turns out this needed to be locked after all. Signed-off-by: Julian Oes --- src/mavsdk/plugins/gimbal/gimbal_impl.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mavsdk/plugins/gimbal/gimbal_impl.cpp b/src/mavsdk/plugins/gimbal/gimbal_impl.cpp index 484b35d89..246121c3d 100644 --- a/src/mavsdk/plugins/gimbal/gimbal_impl.cpp +++ b/src/mavsdk/plugins/gimbal/gimbal_impl.cpp @@ -220,8 +220,7 @@ Gimbal::ControlHandle GimbalImpl::subscribe_control(const Gimbal::ControlCallbac if (result.first) { wait_for_protocol_async([=]() { - // We don't lock here because we don't expect the protocol to change once it has been - // set. + std::lock_guard lock(_mutex); _gimbal_protocol->control_async([this](Gimbal::ControlStatus status) { _control_subscriptions.queue( status, [this](const auto& func) { _system_impl->call_user_callback(func); }); @@ -254,8 +253,7 @@ Gimbal::AttitudeHandle GimbalImpl::subscribe_attitude(const Gimbal::AttitudeCall if (result.first) { wait_for_protocol_async([=]() { - // We don't lock here because we don't expect the protocol to change once it has been - // set. + std::lock_guard lock(_mutex); _gimbal_protocol->attitude_async([this](Gimbal::Attitude attitude) { _attitude_subscriptions.queue( attitude, [this](const auto& func) { _system_impl->call_user_callback(func); });