diff --git a/canconnectioncontainer.cpp b/canconnectioncontainer.cpp index 63a5069..302a3be 100644 --- a/canconnectioncontainer.cpp +++ b/canconnectioncontainer.cpp @@ -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; } diff --git a/canconnectioncontainer.h b/canconnectioncontainer.h index 9ff2b22..8a4a429 100644 --- a/canconnectioncontainer.h +++ b/canconnectioncontainer.h @@ -1,10 +1,9 @@ #ifndef CANCONNECTIONCONTAINER_H #define CANCONNECTIONCONTAINER_H -#include "canconnection.h" #include #include -#include "mainwindow.h" +#include "canconnection.h" class CANConnectionContainer : public QObject {