mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Added exception catches in known problem areas if GCS is closed while it's still connected to a USB device.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2958 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
e4535ed575
commit
f8f25bf2d2
@ -146,11 +146,19 @@ bool ConnectionManager::disconnectDevice()
|
||||
//signal interested plugins that we are disconnecting the device
|
||||
emit deviceDisconnected();
|
||||
|
||||
try
|
||||
{
|
||||
if (m_connectionDevice.connection)
|
||||
{
|
||||
m_connectionDevice.connection->closeDevice(m_connectionDevice.devName);
|
||||
m_ioDev = NULL;
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{ // handle exception
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
|
||||
m_connectBtn->setText("Connect");
|
||||
@ -164,9 +172,20 @@ void ConnectionManager::onConnectionClosed(QObject *obj) // Pip
|
||||
if (!m_connectionDevice.connection || m_connectionDevice.connection != obj)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (m_connectionDevice.connection)
|
||||
{
|
||||
m_connectionDevice.connection->closeDevice(m_connectionDevice.devName);
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{ // handle exception
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
|
||||
m_connectBtn->setText("Connect");
|
||||
m_availableDevList->setEnabled(true);
|
||||
@ -200,7 +219,6 @@ void ConnectionManager::onConnectPressed()
|
||||
if (m_connectionDevice.connection)
|
||||
{
|
||||
m_ioDev = m_connectionDevice.connection->openDevice(m_connectionDevice.devName);
|
||||
|
||||
if (m_ioDev)
|
||||
{
|
||||
m_ioDev->open(QIODevice::ReadWrite);
|
||||
@ -212,7 +230,7 @@ void ConnectionManager::onConnectPressed()
|
||||
|
||||
// TODO: inform the user that something went wrong
|
||||
|
||||
m_connectionDevice.connection = NULL; // Pip
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
return;
|
||||
}
|
||||
@ -239,11 +257,19 @@ void ConnectionManager::onConnectPressed()
|
||||
//signal interested plugins that user is disconnecting his device
|
||||
emit deviceDisconnected();
|
||||
|
||||
try
|
||||
{
|
||||
if (m_connectionDevice.connection)
|
||||
{
|
||||
m_connectionDevice.connection->closeDevice(m_connectionDevice.devName);
|
||||
m_ioDev = NULL;
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{ // handle exception
|
||||
m_connectionDevice.connection = NULL;
|
||||
m_ioDev = NULL;
|
||||
}
|
||||
|
||||
m_connectBtn->setText("Connect");
|
||||
|
Loading…
x
Reference in New Issue
Block a user