From 6aed177634ee971e6828931987bdc2e2dbf75ef0 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 15 Apr 2015 09:37:14 -0700 Subject: [PATCH] Fix connected link check --- .../PX4/AirframeComponentController.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc index 71eee3a7b..d00abe9f0 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc @@ -93,12 +93,20 @@ AirframeComponentController::~AirframeComponentController() void AirframeComponentController::changeAutostart(void) { LinkManager* linkManager = LinkManager::instance(); - - if (linkManager->getLinks().count() > 1) { - QGCMessageBox::warning("Airframe Config", "You cannot change airframe configuration while connected to multiple vehicles."); - return; + + // This shouldn't theoretically be needed since a disconnected link should be deleted. But + // for some reason multiple links are coming up. + int connectedLinkCount = 0; + foreach (LinkInterface* link, linkManager->getLinks()) { + if (link->isConnected()) { + connectedLinkCount++; + } } - + if (connectedLinkCount > 1) { + QGCMessageBox::warning("Airframe Config", "You cannot change airframe configuration while connected to multiple vehicles."); + return; + } + _autoPilotPlugin->getParameterFact("SYS_AUTOSTART")->setValue(_autostartId); _autoPilotPlugin->getParameterFact("SYS_AUTOCONFIG")->setValue(1); -- 2.22.0