fixed thread deletion
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "canconnection.h"
|
#include "canconnection.h"
|
||||||
#include "canconnectioncontainer.h"
|
#include "canconnectioncontainer.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
CANConnectionContainer::CANConnectionContainer(CANConnection *conn)
|
CANConnectionContainer::CANConnectionContainer(CANConnection *conn)
|
||||||
{
|
{
|
||||||
@@ -7,7 +8,6 @@ CANConnectionContainer::CANConnectionContainer(CANConnection *conn)
|
|||||||
connection = conn;
|
connection = conn;
|
||||||
connection->moveToThread(thread);
|
connection->moveToThread(thread);
|
||||||
|
|
||||||
connect(thread, &QThread::finished, conn, &QObject::deleteLater);
|
|
||||||
connect(thread, &QThread::started, conn, &CANConnection::run); //setup timers within the proper thread
|
connect(thread, &QThread::started, conn, &CANConnection::run); //setup timers within the proper thread
|
||||||
connect(conn, &CANConnection::frameUpdateRapid, MainWindow::getReference(), &MainWindow::gotFrames, Qt::QueuedConnection);
|
connect(conn, &CANConnection::frameUpdateRapid, MainWindow::getReference(), &MainWindow::gotFrames, Qt::QueuedConnection);
|
||||||
connect(MainWindow::getReference(), &MainWindow::sendCANFrame, conn, &CANConnection::sendFrame, Qt::QueuedConnection);
|
connect(MainWindow::getReference(), &MainWindow::sendCANFrame, conn, &CANConnection::sendFrame, Qt::QueuedConnection);
|
||||||
@@ -18,6 +18,10 @@ CANConnectionContainer::CANConnectionContainer(CANConnection *conn)
|
|||||||
CANConnectionContainer::~CANConnectionContainer()
|
CANConnectionContainer::~CANConnectionContainer()
|
||||||
{
|
{
|
||||||
//have to stop the actual execution first before deleting
|
//have to stop the actual execution first before deleting
|
||||||
|
thread->quit();
|
||||||
|
if(!thread->wait()) {
|
||||||
|
qDebug() << "can't stop thread";
|
||||||
|
}
|
||||||
delete thread;
|
delete thread;
|
||||||
delete connection;
|
delete connection;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#ifndef CANCONNECTIONCONTAINER_H
|
#ifndef CANCONNECTIONCONTAINER_H
|
||||||
#define CANCONNECTIONCONTAINER_H
|
#define CANCONNECTIONCONTAINER_H
|
||||||
|
|
||||||
#include "canconnection.h"
|
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "mainwindow.h"
|
#include "canconnection.h"
|
||||||
|
|
||||||
class CANConnectionContainer : public QObject
|
class CANConnectionContainer : public QObject
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user