From f741140ad5057e3c47edd93c0d6e78bfa37a1b28 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 20 Apr 2014 23:37:10 +0200 Subject: [PATCH] Fix execution context of thread routines - note that this is not quite the architecture the Qt folks intended, but as they admit its the consequence of their architecture. --- src/comm/QGCFlightGearLink.cc | 4 ++++ src/comm/QGCJSBSimLink.cc | 4 ++++ src/comm/QGCXPlaneLink.cc | 4 ++++ src/comm/SerialLink.cc | 4 ++++ src/comm/TCPLink.cc | 4 ++++ src/comm/UDPLink.cc | 3 +++ 6 files changed, 23 insertions(+) diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index d1d011766..eddd7a5d4 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -49,6 +49,10 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments _sensorHilEnabled(true), barometerOffsetkPa(0.0f) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); + this->host = host; this->port = port+mav->getUASID(); this->connectState = false; diff --git a/src/comm/QGCJSBSimLink.cc b/src/comm/QGCJSBSimLink.cc index c50e517e2..7b56249db 100644 --- a/src/comm/QGCJSBSimLink.cc +++ b/src/comm/QGCJSBSimLink.cc @@ -44,6 +44,10 @@ QGCJSBSimLink::QGCJSBSimLink(UASInterface* mav, QString startupArguments, QStrin process(NULL), startupArguments(startupArguments) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); + this->host = host; this->port = port+mav->getUASID(); this->connectState = false; diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index ef9dfd0c3..1471dce1f 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -58,6 +58,10 @@ QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress simUpdateHz(0), _sensorHilEnabled(true) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); + this->localHost = localHost; this->localPort = localPort/*+mav->getUASID()*/; this->connectState = false; diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index 58f315140..395d9a9d8 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -28,6 +28,10 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, m_stopp(false), m_reqReset(false) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); + // Get the name of the current port in use. m_portName = portname.trimmed(); if (m_portName == "" && getCurrentPorts().size() > 0) diff --git a/src/comm/TCPLink.cc b/src/comm/TCPLink.cc index 0188b549b..a8964db6c 100644 --- a/src/comm/TCPLink.cc +++ b/src/comm/TCPLink.cc @@ -43,6 +43,10 @@ TCPLink::TCPLink(QHostAddress hostAddress, quint16 socketPort) : _socket(NULL), _socketIsConnected(false) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); + _linkId = getNextLinkId(); _resetName(); diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index 101ee15fc..10239d14d 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -42,6 +42,9 @@ This file is part of the QGROUNDCONTROL project UDPLink::UDPLink(QHostAddress host, quint16 port) : socket(NULL) { + // We're doing it wrong - because the Qt folks got the API wrong: + // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ + moveToThread(this); this->host = host; this->port = port; -- 2.22.0