1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS ConnectionManager: Properly check it is the active connection before closing it when a USB device is disconnected.

This commit is contained in:
James Cotton 2012-09-08 14:31:16 -05:00
parent 3563c7376f
commit 1ca8abb3c8

View File

@ -193,8 +193,9 @@ void ConnectionManager::aboutToRemoveObject(QObject *obj)
IConnection *connection = Aggregation::query<IConnection>(obj);
if (!connection) return;
if (m_connectionDevice.connection && m_connectionDevice.connection == connection) // Pip
if (m_connectionDevice.connection && m_connectionDevice.connection == connection)
{ // we are currently using the one that is about to be removed
disconnectDevice();
m_connectionDevice.connection = NULL;
m_ioDev = NULL;
}
@ -204,7 +205,7 @@ void ConnectionManager::aboutToRemoveObject(QObject *obj)
}
void ConnectionManager::onConnectionDestroyed(QObject *obj) // Pip
void ConnectionManager::onConnectionDestroyed(QObject *obj)
{
Q_UNUSED(obj)
//onConnectionClosed(obj);
@ -300,7 +301,7 @@ void ConnectionManager::updateConnectionList(IConnection *connection)
found = true;
if (!found) {
if (m_connectionDevice.connection && m_connectionDevice.connection == connection)
if (m_connectionDevice.connection && m_connectionDevice.connection == connection && m_connectionDevice.device == iter->device)
{ // we are currently using the one we are about to erase
//onConnectionClosed(m_connectionDevice.connection);
disconnectDevice();