Fix SettingClient to get instance.
authorHokwon Song <hokwon.song@samsung.com>
Thu, 12 Sep 2013 02:06:24 +0000 (11:06 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Thu, 12 Sep 2013 02:11:30 +0000 (11:11 +0900)
Change-Id: I18833acf230653280584356b2101021334a852e2
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
src/system/FSys_SettingClient.cpp
src/system/FSys_SettingClient.h

index ecf4b13..1517ee0 100644 (file)
@@ -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);
 }
index fc1333e..a6c0a7b 100644 (file)
@@ -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;