diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index f49d98c0e..41672af1f 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -289,10 +289,11 @@ void ConnectionManager::resumePolling() } /** -* Unregister all devices from one connection plugin -* \param[in] connection Connection type that you want to forget about :) -*/ -void ConnectionManager::unregisterAll(IConnection *connection) + * Synchronize the list of connections displayed with those physically + * present + * @param[in] connection Connection type that you want to forget about :) + */ +void ConnectionManager::updateConnectionList(IConnection *connection) { for (QLinkedList::iterator iter = m_devList.begin(); iter != m_devList.end(); ) { @@ -309,6 +310,16 @@ void ConnectionManager::unregisterAll(IConnection *connection) else ++iter; } + + //and add them back in the list + QList availableDev = connection->availableDevices(); + foreach (IConnection::device dev, availableDev) + { + QString cbName = connection->shortName() + ": " + dev.name; + QString disp = connection->shortName() + " : " + dev.displayName; + registerDevice(connection,cbName,dev.name,disp); + } + } /** @@ -344,16 +355,7 @@ void ConnectionManager::devChanged(IConnection *connection) m_availableDevList->clear(); //remove registered devices of this IConnection from the list - unregisterAll(connection); - - //and add them back in the list - QList availableDev = connection->availableDevices(); - foreach (IConnection::device dev, availableDev) - { - QString cbName = connection->shortName() + ": " + dev.name; - QString disp = connection->shortName() + " : " + dev.displayName; - registerDevice(connection,cbName,dev.name,disp); - } + updateConnectionList(connection); //add all the list again to the combobox foreach (devListItem d, m_devList) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 289e65590..06b7afe39 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -81,7 +81,7 @@ public: void resumePolling(); protected: - void unregisterAll(IConnection *connection); + void updateConnectionList(IConnection *connection); void registerDevice(IConnection *conn, const QString &devN, const QString &name, const QString &disp); devListItem findDevice(const QString &devName); @@ -96,7 +96,6 @@ private slots: void onConnectPressed(); void devChanged(IConnection *connection); -// void onConnectionClosed(QObject *obj); void onConnectionDestroyed(QObject *obj); void connectionsCallBack(); //used to call devChange after all the plugins are loaded protected: