summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-19 10:14:38 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-19 10:14:38 +0200
commit3156ffaf9370171cee9c4de666e0b59f8f46ea9f (patch)
treeacc961674f27007dffb8b37e14829731f657f00b
parent92ada4499ba5036d694a2592e199ec77bd8af97e (diff)
tracker/hatire: connect slots before thread start to prevent races
Issue: #139
-rw-r--r--tracker-hatire/thread.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp
index b77b1ac1..9270b0b7 100644
--- a/tracker-hatire/thread.cpp
+++ b/tracker-hatire/thread.cpp
@@ -81,6 +81,7 @@ void hatire_thread::start()
#ifdef HATIRE_DEBUG_LOGFILE
read_timer.moveToThread(this);
#endif
+
QThread::start();
}
@@ -93,6 +94,12 @@ hatire_thread::~hatire_thread()
hatire_thread::hatire_thread()
{
data_read.reserve(65536);
+
+ connect(this, &QThread::finished, this, &hatire_thread::teardown_serial, Qt::DirectConnection);
+ connect(this, &hatire_thread::init_serial_port, this, &hatire_thread::init_serial_port_impl, Qt::QueuedConnection);
+ connect(this, &hatire_thread::serial_info, this, &hatire_thread::serial_info_impl, Qt::QueuedConnection);
+ connect(this, &hatire_thread::sendcmd, this, &hatire_thread::sendcmd_impl, Qt::QueuedConnection);
+ connect(this, &hatire_thread::sendcmd_str, this, &hatire_thread::sendcmd_str_impl, Qt::QueuedConnection);
}
void hatire_thread::teardown_serial()
@@ -122,12 +129,6 @@ void hatire_thread::teardown_serial()
void hatire_thread::run()
{
- connect(this, &QThread::finished, this, &hatire_thread::teardown_serial, Qt::DirectConnection);
- connect(this, &hatire_thread::init_serial_port, this, &hatire_thread::init_serial_port_impl, Qt::QueuedConnection);
- connect(this, &hatire_thread::serial_info, this, &hatire_thread::serial_info_impl, Qt::QueuedConnection);
- connect(this, &hatire_thread::sendcmd, this, &hatire_thread::sendcmd_impl, Qt::QueuedConnection);
- connect(this, &hatire_thread::sendcmd_str, this, &hatire_thread::sendcmd_str_impl, Qt::QueuedConnection);
-
#ifdef HATIRE_DEBUG_LOGFILE
com_port.setFileName(HATIRE_DEBUG_LOGFILE);
com_port.open(QIODevice::ReadOnly);
@@ -147,8 +148,10 @@ void hatire_thread::run()
serial_result hatire_thread::init_serial_port_impl()
{
#ifndef HATIRE_DEBUG_LOGFILE
+ Log("Setting serial port name");
com_port.setPortName(s.QSerialPortName);
+ Log("Opening serial port");
if (com_port.open(QIODevice::ReadWrite))
{
Log("Port Open");