1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-458 uploadtool: fix QTimer thread ownership issue on windows

This commit is contained in:
Philippe Renon 2017-01-23 23:19:49 +01:00
parent 39fa631670
commit 41b3b39dae
4 changed files with 10 additions and 7 deletions

View File

@ -33,8 +33,7 @@
port::port(QString name, bool debug) : mstatus(port::closed), debug(debug)
{
timer.start();
sport = new QSerialPort();
sport->setPortName(name);
sport = new QSerialPort(name, this);
if (sport->open(QIODevice::ReadWrite)) {
if (sport->setBaudRate(QSerialPort::Baud57600)
&& sport->setDataBits(QSerialPort::Data8)

View File

@ -37,7 +37,9 @@
class QSerialPort;
class port {
class port : public QObject {
Q_OBJECT;
public:
enum portstatus { open, closed, error };

View File

@ -50,7 +50,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
{
numberOfDevices = 0;
serialhandle = NULL;
info = NULL;
port *info = NULL;
qRegisterMetaType<DFU::Status>("Status");
@ -82,6 +82,11 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
return;
}
// transfer ownership of port to serialhandle thread
info->moveToThread(serialhandle);
connect(serialhandle, SIGNAL(finished()), info, SLOT(deleteLater()));
// start the serialhandle thread
serialhandle->start();
} else {
/*
@ -142,7 +147,6 @@ DFUObject::~DFUObject()
{
if (use_serial) {
delete serialhandle;
delete info;
} else {
/*
if (hidHandle) {

View File

@ -40,7 +40,6 @@
#define BUF_LEN 64
// serial
class port;
class qsspt;
// usb
@ -190,7 +189,6 @@ private:
int RWFlags;
// Serial
port *info;
qsspt *serialhandle;
// USB