From: Lars Op den Kamp Date: Mon, 16 Apr 2012 00:26:21 +0000 (+0200) Subject: cec: only delete m_port in CUSBCECAdapterCommunication's destructor. fixes potential... X-Git-Tag: upstream/2.2.0~1^2~31^2~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e4a53f8e9db31df884891ef1f4c5607dd7458ad0;p=deb_libcec.git cec: only delete m_port in CUSBCECAdapterCommunication's destructor. fixes potential 'port is null' error messages when closing the connection --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 5e4a174..d98c205 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -64,6 +64,7 @@ CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void) Close(); delete m_commands; delete m_adapterMessageQueue; + delete m_port; } bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = 10000 */, bool bSkipChecks /* = false */, bool bStartListening /* = true */) @@ -174,8 +175,8 @@ void CUSBCECAdapterCommunication::Close(void) StopThread(0); /* close and delete the com port connection */ - delete m_port; - m_port = NULL; + if (m_port) + m_port->Close(); } cec_adapter_message_state CUSBCECAdapterCommunication::Write(const cec_command &data, uint8_t iMaxTries, uint8_t iLineTimeout /* = 3 */, uint8_t iRetryLineTimeout /* = 3 */)