Browse Source

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.
QGC4.4
Tomaz Canabrava 6 years ago committed by Daniel Agar
parent
commit
3f43bb5e06
  1. 4
      src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc

4
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc

@ -360,7 +360,7 @@ void PX4FirmwarePlugin::_mavCommandResult(int vehicleId, int component, int comm @@ -360,7 +360,7 @@ void PX4FirmwarePlugin::_mavCommandResult(int vehicleId, int component, int comm
Q_UNUSED(component);
Q_UNUSED(noReponseFromVehicle);
Vehicle* vehicle = dynamic_cast<Vehicle*>(sender());
auto* vehicle = qobject_cast<Vehicle*>(sender());
if (!vehicle) {
qWarning() << "Dynamic cast failed!";
return;
@ -520,7 +520,7 @@ void PX4FirmwarePlugin::_handleAutopilotVersion(Vehicle* vehicle, mavlink_messag @@ -520,7 +520,7 @@ void PX4FirmwarePlugin::_handleAutopilotVersion(Vehicle* vehicle, mavlink_messag
{
Q_UNUSED(vehicle);
PX4FirmwarePluginInstanceData* instanceData = qobject_cast<PX4FirmwarePluginInstanceData*>(vehicle->firmwarePluginInstanceData());
auto* instanceData = qobject_cast<PX4FirmwarePluginInstanceData*>(vehicle->firmwarePluginInstanceData());
if (!instanceData->versionNotified) {
bool notifyUser = false;
int supportedMajorVersion = 1;

Loading…
Cancel
Save