Explorar el Código

Cleanup CEC shutdown - removes assertion in Qt5.8

Tobias Hieta hace 8 años
padre
commit
9ee0d75a81
Se han modificado 2 ficheros con 21 adiciones y 12 borrados
  1. 18 8
      src/input/InputCEC.cpp
  2. 3 4
      src/input/InputCEC.h

+ 18 - 8
src/input/InputCEC.cpp

@@ -67,6 +67,17 @@ bool InputCEC::initInput()
   return retVal;
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
+InputCEC::~InputCEC()
+{
+  QMetaObject::invokeMethod(m_cecWorker, "closeCec", Qt::BlockingQueuedConnection);
+
+  m_cecThread->exit(0);
+  m_cecThread->wait();
+
+  delete m_cecWorker;
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////
 bool InputCECWorker::init()
 {
@@ -108,7 +119,7 @@ bool InputCECWorker::init()
   checkAdapter();
 
   // Start a timer to keep track of attached/removed adapters
-  m_timer = new QTimer(this);
+  m_timer = new QTimer(nullptr);
   m_timer->setInterval(10 * 1000);
   connect(m_timer, &QTimer::timeout, this, &InputCECWorker::checkAdapter);
   m_timer->start();
@@ -116,16 +127,15 @@ bool InputCECWorker::init()
   return true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-InputCECWorker::~InputCECWorker()
-{
-  m_timer->stop();
-  closeCec();
-}
-
 //////////////////////////////////////////////////////////////////////////////////////////////////
 void InputCECWorker::closeCec()
 {
+  if (m_timer->isActive())
+  {
+    m_timer->stop();
+    delete m_timer;
+  }
+
   if (m_adapter)
   {
     QLOG_DEBUG() << "Closing libCEC.";

+ 3 - 4
src/input/InputCEC.h

@@ -19,10 +19,12 @@ class InputCEC : public InputBase
 {
 public:
   explicit InputCEC(QObject* parent);
+  ~InputCEC();
 
   const char* inputName() override { return CEC_INPUT_NAME; }
   bool initInput() override;
 
+
 private:
   QThread* m_cecThread;
   InputCECWorker* m_cecWorker;
@@ -37,17 +39,14 @@ public:
   {
   }
 
-  ~InputCECWorker() override;
-
   Q_SLOT bool init();
   Q_SIGNAL void receivedInput(const QString& source, const QString& keycode, InputBase::InputkeyState keyState);
+  Q_SLOT void closeCec();
 
 public slots:
   void checkAdapter();
 
 private:
-  void closeCec();
-
   bool openAdapter();
   void closeAdapter();