From: Jihoon Kim Date: Fri, 28 Jul 2017 11:30:31 +0000 (+0900) Subject: Fix lock issue when getting vconf value X-Git-Tag: accepted/tizen/unified/20170731.020740~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7754bd79b86702ba691f6ac1291113adae7f2ed;p=platform%2Fcore%2Fuifw%2Fisf.git Fix lock issue when getting vconf value Calling vconf_get_XXX function in vconf changed callback leads to lock up. vconf_keynode_get_XXX function would be correct usage. Change-Id: Ia6d502aa09236dc35ca94cfa359e7c67401c5f8e Signed-off-by: Jihoon Kim --- diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index daf0534..e414606 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -278,13 +278,13 @@ static void change_keyboard_mode (TOOLBAR_MODE_T mode); static unsigned int get_ise_index (const String uuid); static bool set_active_ise (const String &uuid, bool launch_ise); static bool update_ise_list (std::vector &list); -static void update_ise_locale (); +static void update_ise_locale (const char *lang = NULL); #ifdef HAVE_NOTIFICATION static void delete_notification (NotificationData *noti_data); static void create_notification (NotificationData *noti_data); static void show_ime_selector_notification (void); #endif -static void set_language_and_locale (void); +static void set_language_and_locale (const char *lang_str); static void app_control_launch (const char *app_id); ///////////////////////////////////////////////////////////////////////////// @@ -6285,16 +6285,29 @@ static void signalhandler (int sig) } #ifdef HAVE_VCONF -static void update_ise_locale () +static void update_ise_locale (const char *language) { - char *lang_str = vconf_get_str (VCONFKEY_LANGSET); - if (lang_str && _locale_string.compare(lang_str) == 0) { - free (lang_str); - return; + String strLang; + + if (language) { + strLang = String (language); } + else { + char *lang_str = vconf_get_str (VCONFKEY_LANGSET); + if (lang_str && _locale_string.compare(lang_str) == 0) { + free (lang_str); + return; + } - LOGD ("update all ISE names according to display language\n"); - set_language_and_locale (); + strLang = String (lang_str); + + if (lang_str) { + free (lang_str); + } + } + + LOGD ("update all ISE names according to display language : %s\n", strLang.c_str ()); + set_language_and_locale (strLang.c_str ()); bool need_to_init_db = false; #ifdef HAVE_PKGMGR_INFO @@ -6338,10 +6351,9 @@ static void update_ise_locale () _initialize_ime_info (); } - if (lang_str) { - isf_db_update_disp_lang(lang_str); - _locale_string = String (lang_str); - free (lang_str); + if (strLang.length () > 0) { + isf_db_update_disp_lang (strLang.c_str ()); + _locale_string = strLang; } } @@ -6350,16 +6362,14 @@ static void update_ise_locale () * * @return void */ -static void set_language_and_locale (void) +static void set_language_and_locale (const char *lang_str) { SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; char language[256]; -#ifdef HAVE_VCONF - char *lang_str = vconf_get_str (VCONFKEY_LANGSET); - if (lang_str) { + LOGD ("language : %s\n", lang_str); #if ISF_BUILD_CANDIDATE_UI elm_language_set (lang_str); #endif /* CANDIDATE */ @@ -6368,12 +6378,10 @@ static void set_language_and_locale (void) setenv ("LANGUAGE", language, 1); setenv ("LANG", lang_str, 1); setlocale (LC_MESSAGES, lang_str); - free (lang_str); } else { setenv ("LANG", "en_US.utf8", 1); setlocale (LC_MESSAGES, "en_US.utf8"); } -#endif /* HAVE_VCONF */ } /** @@ -6388,7 +6396,9 @@ static void display_language_changed_cb (keynode_t *key, void* data) { SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; - set_language_and_locale (); + char *lang_str = vconf_keynode_get_str (key); + LOGD ("lang : %s\n", lang_str); + set_language_and_locale (lang_str); /* Update all ISE names according to display language */ update_ise_locale (); @@ -6413,8 +6423,9 @@ static void display_language_changed_cb (keynode_t *key, void* data) */ static void keyboard_mode_changed_cb (keynode_t *key, void* data) { - int val; - if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) == 0 && val == 0) { + bool val = vconf_keynode_get_bool (key); + + if (val == 0) { _info_manager->reset_keyboard_ise (); change_keyboard_mode (TOOLBAR_HELPER_MODE); _info_manager->update_input_panel_event (ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, 0); @@ -7133,6 +7144,7 @@ int main (int argc, char *argv []) String config_name = String ("simple"); String display_name = String (); char buf[256] = {0}; + char *lang_str = NULL; #ifdef HAVE_ECOREX Ecore_Event_Handler *xclient_message_handler = NULL; @@ -7369,9 +7381,12 @@ int main (int argc, char *argv []) load_config (); check_time ("load_config"); - set_language_and_locale (); - #ifdef HAVE_VCONF + lang_str = vconf_get_str (VCONFKEY_LANGSET); + set_language_and_locale (lang_str); + if (lang_str) + free (lang_str); + /* Add callback function for input language and display language */ vconf_notify_key_changed (VCONFKEY_LANGSET, display_language_changed_cb, NULL); vconf_notify_key_changed (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, keyboard_mode_changed_cb, NULL); diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index a9c1f45..ffe2b52 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -277,12 +277,9 @@ _device_info_send (unsigned int window, Eina_Bool flag) } static void -get_input_language () +set_input_language (const char *input_lang_str) { unsigned int i; - char *input_lang_str = vconf_get_str (VCONFKEY_ISF_INPUT_LANGUAGE); - if (!input_lang_str) return; - LOGD ("language %s", input_lang_str); input_lang = INPUT_LANG_OTHER; for (i = 0; i < (sizeof (__language_infos) / sizeof (__language_infos[0])); i++) { @@ -291,8 +288,6 @@ get_input_language () break; } } - - free (input_lang_str); } static void autoperiod_allow_changed_cb (keynode_t *key, void* data) @@ -307,7 +302,11 @@ static void autocapital_allow_changed_cb (keynode_t *key, void* data) static void input_language_changed_cb (keynode_t *key, void* data) { - get_input_language (); + char *input_lang = vconf_keynode_get_str (key); + if (input_lang) { + set_input_language (input_lang); + LOGD("input lang : %s\n", input_lang); + } } static Eina_Bool @@ -2521,7 +2520,11 @@ void wayland_im_initialize () register_key_handler (); /* get input language vconf value */ - get_input_language (); + char *input_lang_str = vconf_get_str (VCONFKEY_ISF_INPUT_LANGUAGE); + if (input_lang_str) { + set_input_language (input_lang_str); + free (input_lang_str); + } #ifdef HAVE_VCONF /* get autoperiod allow vconf value */