mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Merge remote-tracking branch 'origin/filnet/OP-1393_SerialPlugin_destructor_generates_valgrind_error' into rel-14.06
This commit is contained in:
commit
cacccd985e
@ -37,23 +37,13 @@
|
|||||||
|
|
||||||
|
|
||||||
SerialEnumerationThread::SerialEnumerationThread(SerialConnection *serial)
|
SerialEnumerationThread::SerialEnumerationThread(SerialConnection *serial)
|
||||||
: m_serial(serial),
|
: m_serial(serial), m_running(false)
|
||||||
m_running(true)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SerialEnumerationThread::~SerialEnumerationThread()
|
|
||||||
{
|
|
||||||
m_running = false;
|
|
||||||
// wait for the thread to terminate
|
|
||||||
if (wait(2100) == false) {
|
|
||||||
qDebug() << "Cannot terminate SerialEnumerationThread";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SerialEnumerationThread::run()
|
void SerialEnumerationThread::run()
|
||||||
{
|
{
|
||||||
|
m_running = true;
|
||||||
QList <Core::IConnection::device> devices = m_serial->availableDevices();
|
QList <Core::IConnection::device> devices = m_serial->availableDevices();
|
||||||
|
|
||||||
while (m_running) {
|
while (m_running) {
|
||||||
if (!m_serial->deviceOpened()) {
|
if (!m_serial->deviceOpened()) {
|
||||||
QList <Core::IConnection::device> newDev = m_serial->availableDevices();
|
QList <Core::IConnection::device> newDev = m_serial->availableDevices();
|
||||||
@ -62,11 +52,22 @@ void SerialEnumerationThread::run()
|
|||||||
emit enumerationChanged();
|
emit enumerationChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// update available devices every two seconds (doesn't need more)
|
||||||
msleep(2000); // update available devices every two seconds (doesn't need more)
|
msleep(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SerialEnumerationThread::stop()
|
||||||
|
{
|
||||||
|
if (!m_running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_running = false;
|
||||||
|
// wait for the thread to terminate
|
||||||
|
if (wait(2100) == false) {
|
||||||
|
qDebug() << "Cannot terminate SerialEnumerationThread";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SerialConnection::SerialConnection() :
|
SerialConnection::SerialConnection() :
|
||||||
serialHandle(NULL),
|
serialHandle(NULL),
|
||||||
@ -100,7 +101,9 @@ SerialConnection::SerialConnection() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
SerialConnection::~SerialConnection()
|
SerialConnection::~SerialConnection()
|
||||||
{}
|
{
|
||||||
|
m_enumerateThread.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void SerialConnection::onEnumerationChanged()
|
void SerialConnection::onEnumerationChanged()
|
||||||
{
|
{
|
||||||
@ -199,7 +202,7 @@ void SerialConnection::resumePolling()
|
|||||||
enablePolling = true;
|
enablePolling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialPlugin::SerialPlugin()
|
SerialPlugin::SerialPlugin() : m_connection(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SerialPlugin::~SerialPlugin()
|
SerialPlugin::~SerialPlugin()
|
||||||
|
@ -51,10 +51,11 @@ class SerialEnumerationThread : public QThread {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SerialEnumerationThread(SerialConnection *serial);
|
SerialEnumerationThread(SerialConnection *serial);
|
||||||
virtual ~SerialEnumerationThread();
|
|
||||||
|
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
|
void stop();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enumerationChanged();
|
void enumerationChanged();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user