From: Hokwon Song Date: Thu, 26 Sep 2013 00:31:23 +0000 (+0900) Subject: Fixed get instance for setting client. X-Git-Tag: accepted/tizen/20131018.104622~8^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5154aa950bd3e75f4395aadf9f573a59c2218e03;p=platform%2Fframework%2Fnative%2Fappfw.git Fixed get instance for setting client. Change-Id: I911b3b1b15c1e0fa40785ebd5a23c886ab3cdea0 Signed-off-by: Hokwon Song --- diff --git a/src/system/FSys_SettingClient.cpp b/src/system/FSys_SettingClient.cpp index 1517ee0..4ac1a3a 100644 --- a/src/system/FSys_SettingClient.cpp +++ b/src/system/FSys_SettingClient.cpp @@ -174,8 +174,13 @@ int common_service = 1; void _SettingClient::InitSettingClient(void) { - __pSettingClient = new (std::nothrow) _SettingClient(); - SysTryReturn(NID_SYS, __pSettingClient, , GetLastResult(), "It is failed to create SettingClient by [%s].", GetErrorMessage(GetLastResult())); + unique_ptr<_SettingClient> pSettingClient(new (std::nothrow) _SettingClient()); + SysTryReturn(NID_SYS, pSettingClient, ,E_OUT_OF_MEMORY, "It is failed to create SettingClient by [E_OUT_OF_MEMORY]."); + + result r = pSettingClient->Construct(); + SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "It is failed to create SettingClient by [%s].", GetErrorMessage(r)); + + __pSettingClient = pSettingClient.release(); atexit(DestroySettingClient); } @@ -183,6 +188,7 @@ void _SettingClient::DestroySettingClient(void) { delete __pSettingClient; + __pSettingClient = null; } _SettingClient* @@ -204,28 +210,6 @@ _SettingClient::_SettingClient() , __pSettingEvent(null) , __pSettingEventForInternal(null) { - result r = E_SUCCESS; - static String serviceId(SETTING_SERVICE_ID); - - unique_ptr<_SettingEvent> settingEvent(new(nothrow) _SettingEvent()); - unique_ptr<_SettingEvent> settingEventForInternal(new(nothrow) _SettingEvent()); - unique_ptr<_IpcClient> pIpcClient(new (nothrow) _IpcClient()); - - 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."); - - SysTryCatch(NID_SYS, settingEvent.get() != null && settingEventForInternal.get() != null, r = E_SYSTEM, r, "It is failed to create event instances."); - -CATCH: - if(r == E_SUCCESS) - { - __pSettingEvent = settingEvent.release(); - __pSettingEventForInternal = settingEventForInternal.release(); - __pIpcClient = pIpcClient.release(); - } - SetLastResult(r); } _SettingClient::~_SettingClient() @@ -245,6 +229,30 @@ _SettingClient::~_SettingClient() } } +result +_SettingClient::Construct(void) +{ + result r = E_SUCCESS; + + static String serviceId(SETTING_SERVICE_ID); + + unique_ptr<_SettingEvent> settingEvent(new(nothrow) _SettingEvent()); + unique_ptr<_SettingEvent> settingEventForInternal(new(nothrow) _SettingEvent()); + unique_ptr<_IpcClient> pIpcClient(new (nothrow) _IpcClient()); + + r = pIpcClient->Construct(serviceId, this); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct IPC client."); + r = __asyncEventList.Construct(); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct asyn event list."); + + SysTryReturnResult(NID_SYS, settingEvent != null && settingEventForInternal != null, r, "It is failed to create event instances."); + + __pSettingEvent = settingEvent.release(); + __pSettingEventForInternal = settingEventForInternal.release(); + __pIpcClient = pIpcClient.release(); + return E_SUCCESS; +} + void _SettingClient::OnIpcServerDisconnected(_IpcClient& client) { diff --git a/src/system/FSys_SettingClient.h b/src/system/FSys_SettingClient.h index a6c0a7b..653a707 100644 --- a/src/system/FSys_SettingClient.h +++ b/src/system/FSys_SettingClient.h @@ -136,11 +136,11 @@ class _SettingClient : public Tizen::Base::Object , public Tizen::Io::_IIpcClientEventListener { -private: +public: _SettingClient(void); virtual ~_SettingClient(void); -public: + result Construct(void); result GetValue(const Tizen::Base::String& key, bool& value); result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value); result GetValue(const Tizen::Base::String& key, double& value);