From 3f43bb5e06c2044452dd1cbc85f2ba57a8398265 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 19 Aug 2019 11:33:31 +0200 Subject: [PATCH] PX4FirmwarePlugin: use qobject_cast instead of dynamic_cast qobject_cast is times faster dynamic_cast for objects that inherit QObject. also, use auto keyword to not duplicate class names. --- src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc index ca9727a5d9..19cad429d2 100644 --- a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc +++ b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc @@ -360,7 +360,7 @@ void PX4FirmwarePlugin::_mavCommandResult(int vehicleId, int component, int comm Q_UNUSED(component); Q_UNUSED(noReponseFromVehicle); - Vehicle* vehicle = dynamic_cast(sender()); + auto* vehicle = qobject_cast(sender()); if (!vehicle) { qWarning() << "Dynamic cast failed!"; return; @@ -520,7 +520,7 @@ void PX4FirmwarePlugin::_handleAutopilotVersion(Vehicle* vehicle, mavlink_messag { Q_UNUSED(vehicle); - PX4FirmwarePluginInstanceData* instanceData = qobject_cast(vehicle->firmwarePluginInstanceData()); + auto* instanceData = qobject_cast(vehicle->firmwarePluginInstanceData()); if (!instanceData->versionNotified) { bool notifyUser = false; int supportedMajorVersion = 1; -- GitLab