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

Merge remote-tracking branch 'origin/filnet/OP-1383_fixed_GCS_crashes_when_using_serial_connections' into rel-14.06

This commit is contained in:
Alessio Morale 2014-07-16 20:00:32 +02:00
commit f6ab4cdfb1
4 changed files with 13 additions and 10 deletions

View File

@ -83,10 +83,6 @@ public:
void init();
QIODevice *getCurrentConnection()
{
return m_ioDev;
}
DevListItem getCurrentDevice()
{
return m_connectionDevice;

View File

@ -264,7 +264,7 @@ void ScopeGadgetWidget::preparePlot(PlotType plotType)
// Only start the timer if we are already connected
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
if (cm->getCurrentConnection() && replotTimer) {
if (cm->isConnected() && replotTimer) {
if (!replotTimer->isActive()) {
replotTimer->start(m_refreshInterval);
} else {

View File

@ -146,15 +146,17 @@ QIODevice *SerialConnection::openDevice(const QString &deviceName)
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
foreach(QSerialPortInfo port, ports) {
if (port.portName() == deviceName) {
// don't specify a parent when constructing the QSerialPort as this object will be moved
// to a different thread later on (see telemetrymanager.cpp)
serialHandle = new QSerialPort(port);
// we need to handle port settings here...
qDebug() << "Serial telemetry running at " << m_config->speed();
serialHandle = new QSerialPort(port, this);
if (serialHandle->open(QIODevice::ReadWrite)) {
if (serialHandle->setBaudRate(m_config->speed().toInt())
&& serialHandle->setDataBits(QSerialPort::Data8)
&& serialHandle->setParity(QSerialPort::NoParity)
&& serialHandle->setStopBits(QSerialPort::OneStop)
&& serialHandle->setFlowControl(QSerialPort::NoFlowControl)) {
qDebug() << "Serial telemetry running at " << m_config->speed();
m_deviceOpened = true;
}
}
@ -170,12 +172,11 @@ void SerialConnection::closeDevice(const QString &deviceName)
// we have to delete the serial connection we created
if (serialHandle) {
serialHandle->deleteLater();
serialHandle = NULL;
m_deviceOpened = false;
serialHandle = NULL;
}
m_deviceOpened = false;
}
QString SerialConnection::connectionName()
{
return QString("Serial port");

View File

@ -53,6 +53,12 @@ bool TelemetryManager::isConnected()
void TelemetryManager::start(QIODevice *dev)
{
device = dev;
// OP-1383
// take ownership of the device by moving it to the TelemetryManager thread (see TelemetryManager constructor)
// this removes the following runtime Qt warning and incidentally fixes GCS crashes:
// QObject: Cannot create children for a parent that is in a different thread.
// (Parent is QSerialPort(0x56af73f8), parent's thread is QThread(0x23f69ae8), current thread is QThread(0x2649cfd8)
device->moveToThread(thread());
emit myStart();
}