diff --git a/src/AutoPilotPlugins/AutoPilotPluginManager.cc b/src/AutoPilotPlugins/AutoPilotPluginManager.cc index a18cb4eb96965d62b4af305a0f0a1a988887a20d..086400fe242e711f6784fd9ffa5c1fd5748cd444 100644 --- a/src/AutoPilotPlugins/AutoPilotPluginManager.cc +++ b/src/AutoPilotPlugins/AutoPilotPluginManager.cc @@ -40,7 +40,7 @@ AutoPilotPluginManager::AutoPilotPluginManager(QObject* parent) : // We need to track uas coming and going so that we can instantiate plugins for each uas connect(uasMgr, &UASManagerInterface::UASCreated, this, &AutoPilotPluginManager::_uasCreated); - connect(uasMgr, &UASManagerInterface::UASDeleted, this, &AutoPilotPluginManager::_uasDeleted); + connect(uasMgr, SIGNAL(UASDeleted(UASInterface*)), this, SLOT(_uasDeleted(UASInterface*))); } AutoPilotPluginManager::~AutoPilotPluginManager() diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index e680b641e467f57eaa8d545ff950cd2fc2d8cb55..98e7f63d999030193084c5c6754fc4666f7a0413 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -237,15 +237,16 @@ void QGCXPlaneLink::run() QGC::SLEEP::msleep(5); } - if (mav) + uas = dynamic_cast(mav); + if (uas) { - disconnect(mav, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - disconnect(mav, SIGNAL(hilActuatorsChanged(quint64, float, float, float, float, float, float, float, float)), this, SLOT(updateActuators(quint64,float,float,float,float,float,float,float,float))); + disconnect(uas, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); + disconnect(uas, SIGNAL(hilActuatorsChanged(quint64, float, float, float, float, float, float, float, float)), this, SLOT(updateActuators(quint64,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(hilGroundTruthChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilGroundTruth(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(sensorHilGpsChanged(quint64,double,double,double,int,float,float,float,float,float,float,float,int)), mav, SLOT(sendHilGps(quint64,double,double,double,int,float,float,float,float,float,float,float,int))); - disconnect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), mav, SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); + disconnect(this, SIGNAL(hilGroundTruthChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), uas, SLOT(sendHilGroundTruth(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); + disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), uas, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); + disconnect(this, SIGNAL(sensorHilGpsChanged(quint64,double,double,double,int,float,float,float,float,float,float,float,int)), uas, SLOT(sendHilGps(quint64,double,double,double,int,float,float,float,float,float,float,float,int))); + disconnect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), uas, SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); // Do not toggle HIL state on the UAS - this is not the job of this link, but of the // UAS object diff --git a/src/uas/UASManager.cc b/src/uas/UASManager.cc index 5e015709f997cd749f5c26c2df00f8a4c6a36acf..23ccb3a64d95dce30a630ebfd73c1f37db138657 100644 --- a/src/uas/UASManager.cc +++ b/src/uas/UASManager.cc @@ -340,6 +340,7 @@ void UASManager::removeUAS(UASInterface* uas) // Notify other UI elements that a UAS is being deleted before finally deleting it. qDebug() << "Deleting UAS object: " << uas->getUASName(); emit UASDeleted(uas); + emit UASDeleted(uas->getUASID()); uas->deleteLater(); } } diff --git a/src/uas/UASManagerInterface.h b/src/uas/UASManagerInterface.h index c96c32655bef43cbca91c4d01d0e1555033604f6..cadf92bb827affdc155023ded5a01bbcb1658642 100644 --- a/src/uas/UASManagerInterface.h +++ b/src/uas/UASManagerInterface.h @@ -98,6 +98,8 @@ signals: void UASCreated(UASInterface* UAS); /** A system was deleted */ void UASDeleted(UASInterface* UAS); + /** A system was deleted */ + void UASDeleted(int systemId); /** @brief The UAS currently under main operator control changed */ void activeUASSet(UASInterface* UAS); /** @brief The UAS currently under main operator control changed */ diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 57b97d5b136161cac1874a7ec842bdc7bca777d4..f0bb967a0cdd2779cd9233d227a66a16d7008d23 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -796,6 +796,7 @@ void MainWindow::connectCommonActions() // Connect internal actions connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(UASCreated(UASInterface*))); + connect(UASManager::instance(), SIGNAL(UASDeleted(int)), this, SLOT(UASDeleted(int))); // Unmanned System controls connect(_ui.actionLiftoff, SIGNAL(triggered()), UASManager::instance(), SLOT(launchActiveUAS())); @@ -909,6 +910,14 @@ void MainWindow::UASCreated(UASInterface* uas) } } +void MainWindow::UASDeleted(int uasId) +{ + if (_mapUasId2HilDockWidget.contains(uasId)) { + _mapUasId2HilDockWidget[uasId]->deleteLater(); + _mapUasId2HilDockWidget.remove(uasId); + } +} + /// Stores the state of the toolbar, status bar and widgets associated with the current view void MainWindow::_storeCurrentViewState(void) { diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4ba330997b9fb836823129135b38e8de725179ff..a337268e0706b0c5f84bf0828f928d53ee58927c 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -146,6 +146,9 @@ public slots: /** @brief Add a new UAS */ void UASCreated(UASInterface* uas); + /** @brief Remove an old UAS */ + void UASDeleted(int uasID); + void handleMisconfiguration(UASInterface* uas); /** @brief Load configuration views */ void loadSetupView(); diff --git a/src/ui/QGCHilConfiguration.cc b/src/ui/QGCHilConfiguration.cc index 61bed1ac64386d330067c61905c3a4a5d022ed54..58bca7e14ae9730446f8b6661885c71849026116 100644 --- a/src/ui/QGCHilConfiguration.cc +++ b/src/ui/QGCHilConfiguration.cc @@ -29,6 +29,8 @@ QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) : } settings.endGroup(); + + connect(mav, SIGNAL(destroyed()), this, SLOT(deleteLater())); } void QGCHilConfiguration::receiveStatusMessage(const QString& message)