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