Skip to content

Commit

Permalink
gimbal: fix unregister message subscription
Browse files Browse the repository at this point in the history
We should unregister anything we have subscribed to when being
destructed.

Signed-off-by: Julian Oes <julian@oes.ch>
  • Loading branch information
julianoes committed Jan 12, 2024
1 parent fa92af4 commit 5157b1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/mavsdk/plugins/gimbal/gimbal_protocol_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ GimbalProtocolV2::GimbalProtocolV2(
_gimbal_manager_compid(gimbal_manager_compid)
{}

GimbalProtocolV2::~GimbalProtocolV2()
{
if (_is_mavlink_manager_status_registered) {
_is_mavlink_manager_status_registered = false;

_system_impl.unregister_mavlink_message_handler(MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS, this);
}
}

void GimbalProtocolV2::process_gimbal_manager_status(const mavlink_message_t& message)
{
Gimbal::ControlMode new_control_mode;
Expand Down
2 changes: 1 addition & 1 deletion src/mavsdk/plugins/gimbal/gimbal_protocol_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GimbalProtocolV2 : public GimbalProtocolBase {
const mavlink_gimbal_manager_information_t& information,
uint8_t gimbal_manager_sysid,
uint8_t gimbal_manager_compid);
~GimbalProtocolV2() override = default;
~GimbalProtocolV2() override;

Gimbal::Result set_pitch_and_yaw(float pitch_deg, float yaw_deg) override;
void set_pitch_and_yaw_async(
Expand Down

0 comments on commit 5157b1a

Please sign in to comment.