Optimize font change code
authorJoohyun Kim <joohyune.kim@samsung.com>
Tue, 21 May 2013 01:09:07 +0000 (10:09 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Tue, 21 May 2013 01:20:53 +0000 (10:20 +0900)
Change-Id: I74a2a123a59ecceb1e2723b7d92cf9fe4f9219f8
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
src/system/FSys_SettingInfoImpl.cpp

index 34f1ee0..bea42de 100644 (file)
@@ -18,6 +18,7 @@
  * @file               FSys_SettingInfoImpl.cpp
  * @brief              This is the implementation file for _SysSettingInfoImpl class.
  */
+#include <unique_ptr.h>
 #include <system/system_settings.h>
 
 #include <FBase.h>
 #include <FBase_StringConverter.h>
 #include <FBase_NativeError.h>
 #include <FSys_SettingInfoImpl.h>
+
 #include "FSys_SettingClient.h"
 
+using namespace std;
+
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -477,15 +481,14 @@ _SettingInfoImpl::SetValueForFont(const Tizen::Base::String& key, Tizen::Base::S
        }
        else if(key == _FONT_TYPE)
        {
-               char* pFontType = null;
                int res = 0;
                r = E_SUCCESS;
 
-               pFontType = _StringConverter::CopyToCharArrayN(value);
-               SysTryReturnResult(NID_SYS, pFontType != null, E_SYSTEM, "It is failed to convert String to string.");
-               SysLog(NID_SYS, "Requested font type is %s.", pFontType);
-               res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType);
-               delete [] pFontType;
+               unique_ptr<char[]> pFontType(_StringConverter::CopyToCharArrayN(value));
+               SysTryReturnResult(NID_SYS, pFontType.get() != null, E_SYSTEM, "It is failed to convert String to string.");
+               SysLog(NID_SYS, "Requested font type is %s.", pFontType.get());
+               res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType.get());
+               SysTryReturnResult(NID_SYS, res != SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, "It is not valid font type.");
                SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font type.");
        }
        return r;