cec: close and delete the connection when the processor thread ends. fixes reconnect...
[deb_libcec.git] / src / lib / adapter / USBCECAdapterCommunication.cpp
index e2b03862d437cf75da03dda403a94e3da4e8f600..a3b7c459837e017ce75aca543b0190a6a30d3d6c 100644 (file)
@@ -55,12 +55,6 @@ CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(CCECProcessor *processo
 CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
 {
   Close();
-
-  if (m_port)
-  {
-    delete m_port;
-    m_port = NULL;
-  }
 }
 
 bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = 10000 */)
@@ -143,6 +137,12 @@ void *CUSBCECAdapterCommunication::Process(void)
   if (m_outBuffer.Pop(msg))
     msg->condition.Broadcast();
 
+  if (m_port)
+  {
+    delete m_port;
+    m_port = NULL;
+  }
+
   return NULL;
 }