Commit e0d94b4d authored by dogmaphobic's avatar dogmaphobic

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.
parent 3fd9497c
......@@ -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 */
......
......@@ -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<LinkInterface*> 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));
......
......@@ -123,7 +123,7 @@ private slots:
void _updateConfigurations();
private:
void _updateConnectButton(void);
void _updateConnectButton(LinkInterface* disconnectedLink = NULL);
LinkManager* _linkMgr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment