diff --git a/src/mavsdk/core/mavlink_ftp_client.cpp b/src/mavsdk/core/mavlink_ftp_client.cpp index 156f7a9cce..e4e74f051a 100644 --- a/src/mavsdk/core/mavlink_ftp_client.cpp +++ b/src/mavsdk/core/mavlink_ftp_client.cpp @@ -26,7 +26,10 @@ MavlinkFtpClient::MavlinkFtpClient(SystemImpl& system_impl) : _system_impl(syste this); } -MavlinkFtpClient::~MavlinkFtpClient() {} +MavlinkFtpClient::~MavlinkFtpClient() +{ + _system_impl.unregister_all_mavlink_message_handlers(this); +} void MavlinkFtpClient::do_work() { diff --git a/src/mavsdk/core/mavlink_ftp_server.cpp b/src/mavsdk/core/mavlink_ftp_server.cpp index f61d555680..2bad1793f2 100644 --- a/src/mavsdk/core/mavlink_ftp_server.cpp +++ b/src/mavsdk/core/mavlink_ftp_server.cpp @@ -190,6 +190,8 @@ void MavlinkFtpServer::process_mavlink_ftp_message(const mavlink_message_t& msg) MavlinkFtpServer::~MavlinkFtpServer() { + _server_component_impl.unregister_all_mavlink_message_handlers(this); + std::lock_guard lock(_mutex); _reset(); }