From 590ee7778b66f7c036d94302a97d17a46b8dcb49 Mon Sep 17 00:00:00 2001 From: Hokwon Song Date: Thu, 12 Sep 2013 11:06:24 +0900 Subject: [PATCH] Fix SettingClient to get instance. Change-Id: I18833acf230653280584356b2101021334a852e2 Signed-off-by: Hokwon Song --- src/system/FSys_SettingClient.cpp | 19 ++++++++++++++----- src/system/FSys_SettingClient.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/system/FSys_SettingClient.cpp b/src/system/FSys_SettingClient.cpp index ecf4b13..1517ee0 100644 --- a/src/system/FSys_SettingClient.cpp +++ b/src/system/FSys_SettingClient.cpp @@ -174,8 +174,15 @@ int common_service = 1; void _SettingClient::InitSettingClient(void) { - static _SettingClient settingManager; - __pSettingClient = &settingManager; + __pSettingClient = new (std::nothrow) _SettingClient(); + SysTryReturn(NID_SYS, __pSettingClient, , GetLastResult(), "It is failed to create SettingClient by [%s].", GetErrorMessage(GetLastResult())); + atexit(DestroySettingClient); +} + +void +_SettingClient::DestroySettingClient(void) +{ + delete __pSettingClient; } _SettingClient* @@ -190,7 +197,8 @@ _SettingClient::GetInstance(void) } _SettingClient::_SettingClient() - : __subscribed(false) + : __pIpcClient(null) + , __subscribed(false) , __subscribedForInternal(false) , __pListener(null) , __pSettingEvent(null) @@ -201,9 +209,9 @@ _SettingClient::_SettingClient() unique_ptr<_SettingEvent> settingEvent(new(nothrow) _SettingEvent()); unique_ptr<_SettingEvent> settingEventForInternal(new(nothrow) _SettingEvent()); + unique_ptr<_IpcClient> pIpcClient(new (nothrow) _IpcClient()); - __pIpcClient = new (nothrow) _IpcClient(); - r = __pIpcClient->Construct(serviceId, this); + r = pIpcClient->Construct(serviceId, this); SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to construct IPC client."); r = __asyncEventList.Construct(); SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to construct asyn event list."); @@ -215,6 +223,7 @@ CATCH: { __pSettingEvent = settingEvent.release(); __pSettingEventForInternal = settingEventForInternal.release(); + __pIpcClient = pIpcClient.release(); } SetLastResult(r); } diff --git a/src/system/FSys_SettingClient.h b/src/system/FSys_SettingClient.h index fc1333e..a6c0a7b 100644 --- a/src/system/FSys_SettingClient.h +++ b/src/system/FSys_SettingClient.h @@ -187,6 +187,7 @@ private: result SubscribeEvent(void); static void InitSettingClient(void); + static void DestroySettingClient(void); private: Tizen::Base::Collection::HashMap __asyncEventList; Tizen::Io::_IpcClient* __pIpcClient; -- 2.7.4