From cc497c43dc6cd6e138295d5cabe7949964f78bba Mon Sep 17 00:00:00 2001 From: ligi Date: Fri, 22 Oct 2010 11:17:48 +0000 Subject: [PATCH] check if opening a device worked / prevents segfaults ( e.g. failing BT connection ) & checking if my svn account works ;-) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2000 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/coreplugin/connectionmanager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ground/src/plugins/coreplugin/connectionmanager.cpp b/ground/src/plugins/coreplugin/connectionmanager.cpp index c6250047e..0d9950077 100644 --- a/ground/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/src/plugins/coreplugin/connectionmanager.cpp @@ -141,6 +141,16 @@ void ConnectionManager::onConnectPressed() if(m_ioDev) { m_ioDev->open(QIODevice::ReadWrite); + + // check if opening the device worked + if (!m_ioDev->isOpen()) + { + qDebug() << "could not connect to " << m_connectionDevice.devName; + // TODO: inform the user that something went wrong + m_ioDev = NULL; + return; + } + //signal interested plugins that the user wants to connect to the device emit deviceConnected(m_ioDev); m_connectBtn->setText("Disconnect");