Index: lib/Comms/src/CanInterface.cpp =================================================================== diff -u -rcfc0df719cb5033078d0cac45ce0f6243810f2e7 -r59b4c22f45a1d098064a886452769204e90cfb4b --- lib/Comms/src/CanInterface.cpp (.../CanInterface.cpp) (revision cfc0df719cb5033078d0cac45ce0f6243810f2e7) +++ lib/Comms/src/CanInterface.cpp (.../CanInterface.cpp) (revision 59b4c22f45a1d098064a886452769204e90cfb4b) @@ -104,41 +104,16 @@ initConnections(); + // Close the CAN device on application exit + connect(qApp, &QCoreApplication::aboutToQuit, this, &CanInterface::quitDevice); + status(QString("Connected")); qDebug().noquote() << QString("UI,%1,%2").arg(QString("%1 Initialized").arg(metaObject()->className())).arg(status()); return true; } /*! - * \brief CanInterface::init - * \details Initialized the Class by calling the init() method first - * And initializes the thread vThread by calling initThread - * on success init(). - * \param vThread - the thread - * \return returns the return value of the init() method - */ -bool CanInterface::init(QThread &vThread) -{ - qDebug().noquote() << "*** CanInterface::init"; // SQ - if (! init()) { - return false; - } - initThread(vThread); - return true; -} - -/*! - * \brief CanInterface quit - * \details quits the class - * Calls quitThread - */ -void CanInterface::quit() -{ - quitThread(); // verified -} - -/*! * \brief frameFlags * \details CANBus message frame type as flags * \param vFrame - CANBus message frame @@ -226,37 +201,6 @@ } /*! - * \brief CanInterface::initThread - * \details Moves this object into the thread vThread. - * And checks that this method is called from main thread. - * Also connects quitThread to application aboutToQuit. - * \param vThread - the thread - */ -void CanInterface::initThread(QThread &vThread) -{ - qDebug().noquote() << "*** CanInterface::initThread"; // SQ - // runs in main thread - Q_ASSERT_X(QThread::currentThread() == qApp->thread() , __func__, "The Class initialization must be done in Main Thread" ); - vThread.setObjectName(QString("%1_Thread").arg(metaObject()->className())); - connect(qApp, &QCoreApplication::aboutToQuit, this, &CanInterface::quit); - moveToThread(&vThread); - vThread.start(); -} - -/*! - * \brief CanInterface::quitThread - * \details Moves this object to main thread to be handled by QApplication - * And to be destroyed there. - */ -void CanInterface::quitThread() -{ - // runs in thread - if (QThread::currentThread() == qApp->thread()) { - moveToThread(qApp->thread()); // verified - } -} - -/*! * \brief CanInterface status * \details Sets the Can interface status description * \param vDescription - Description about the CANBus Interface errors