diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 5db9889..7b004eb 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -519,8 +519,7 @@ Vehicle::~Vehicle() delete _mav; _mav = nullptr; - delete _gimbalController; - _gimbalController = nullptr; + deleteGimbalController(); } void Vehicle::prepareDelete() @@ -536,6 +535,14 @@ void Vehicle::prepareDelete() } } +void Vehicle::deleteGimbalController() +{ + if (_gimbalController) { + delete _gimbalController; + _gimbalController = nullptr; + } +} + void Vehicle::_offlineFirmwareTypeSettingChanged(QVariant varFirmwareType) { _firmwareType = static_cast(varFirmwareType.toInt()); diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index eda6214..c54b6bb 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -898,6 +898,9 @@ public: /// Vehicle is about to be deleted void prepareDelete(); + /// Delete gimbal controller, handy for RequestMessageTest.cc, otherwise gimbal controller message requests will mess with this test + void deleteGimbalController(); + quint64 mavlinkSentCount () const{ return _mavlinkSentCount; } /// Calculated total number of messages sent to us quint64 mavlinkReceivedCount () const{ return _mavlinkReceivedCount; } /// Total number of sucessful messages received quint64 mavlinkLossCount () const{ return _mavlinkLossCount; } /// Total number of lost messages