From ea0cdc520b822dab106a4daaab3480546dbbd04f Mon Sep 17 00:00:00 2001 From: Joohyun Kim Date: Fri, 19 Apr 2013 14:13:13 +0900 Subject: [PATCH] Fix SerialPort instance management Change-Id: I6027dc2d2c20b28979757f773256a428abd37c08 Signed-off-by: Joohyun Kim --- src/io/FIoSerialPort.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/io/FIoSerialPort.cpp b/src/io/FIoSerialPort.cpp index ed1389a..1b2e060 100644 --- a/src/io/FIoSerialPort.cpp +++ b/src/io/FIoSerialPort.cpp @@ -68,11 +68,11 @@ SerialPort::Construct(ISerialPortEventListener& listener) __pSerialPortImpl = _SerialPortImpl::GetInstance(); SysTryReturnResult(NID_IO, __pSerialPortImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient."); - SysTryReturnResult(NID_IO, __pSerialPortImpl->IsOpended() == false, E_SYSTEM, "SerialPort is already opened."); + SysTryCatch(NID_IO, __pSerialPortImpl->IsOpended() == false, r = E_SYSTEM, r, "SerialPort is already opened."); SysLog(NID_IO, "Try to open serialport"); r = __pSerialPortImpl->SerialOpen(); - SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "It is failed to open serial port."); + SysTryCatch(NID_IO, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to open serial port."); SysLog(NID_IO, "Try to register event"); r = __pSerialPortImpl->SetSerialPortEventListener(listener); @@ -80,10 +80,15 @@ SerialPort::Construct(ISerialPortEventListener& listener) { SysLogException(NID_IO, E_SYSTEM, "It is failed to register event listener."); r = __pSerialPortImpl->SerialClose(); - SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "It is failed to close serial port."); + SysTryCatch(NID_IO, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to close serial port."); r = E_SYSTEM; } +CATCH: + if(r != E_SUCCESS) + { + __pSerialPortImpl = null; + } return r; } @@ -101,7 +106,6 @@ int SerialPort::GetWriteBufferSize(void) const { SysAssertf(__pSerialPortImpl != null, "Not yet constructed. Construct() should be called before use.\n"); - return __pSerialPortImpl->GetWriteBufferSize(); } -- 2.7.4