From e0d94b4dea5a19833802a2e6b02fcfe9e1c9b28e Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Sat, 14 Feb 2015 11:09:24 -0500 Subject: [PATCH] Fixing asynchronous issue with link disconnect. I noticed that some times, the disconnect signal would get to the updateConnect button (tool bar) before the link was physically disconnected. That would cause it to count it as a still connected link and get the connect button logic out of sync. While at it, added an interface to the UDP link to return its configuration instance. That allows the LinkManager to unlink it when disconnecting it. --- src/comm/UDPLink.h | 2 ++ src/ui/QGCToolBar.cc | 7 +++---- src/ui/QGCToolBar.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/comm/UDPLink.h b/src/comm/UDPLink.h index fd30eae97..471f151aa 100644 --- a/src/comm/UDPLink.h +++ b/src/comm/UDPLink.h @@ -164,6 +164,8 @@ public: bool connect(void); bool disconnect(void); + LinkConfiguration* getLinkConfiguration() { return _config; } + public slots: /*! @brief Add a new host to broadcast messages to */ diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index cbd0376a4..9dc5e1314 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -585,18 +585,17 @@ void QGCToolBar::_linkConnected(LinkInterface* link) void QGCToolBar::_linkDisconnected(LinkInterface* link) { - Q_UNUSED(link); - _updateConnectButton(); + _updateConnectButton(link); } -void QGCToolBar::_updateConnectButton(void) +void QGCToolBar::_updateConnectButton(LinkInterface *disconnectedLink) { QMenu* menu = new QMenu(this); // If there are multiple connected links add/update the connect button menu int connectedCount = 0; QList links = _linkMgr->getLinks(); foreach(LinkInterface* link, links) { - if (link->isConnected()) { + if (disconnectedLink != link && link->isConnected()) { connectedCount++; QAction* action = menu->addAction(link->getName()); action->setData(QVariant::fromValue((void*)link)); diff --git a/src/ui/QGCToolBar.h b/src/ui/QGCToolBar.h index ca6e86e7c..64d33c9f0 100644 --- a/src/ui/QGCToolBar.h +++ b/src/ui/QGCToolBar.h @@ -123,7 +123,7 @@ private slots: void _updateConfigurations(); private: - void _updateConnectButton(void); + void _updateConnectButton(LinkInterface* disconnectedLink = NULL); LinkManager* _linkMgr; -- 2.22.0