Fix crash issue occured when terminating 73/165973/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 5 Jan 2018 01:01:15 +0000 (10:01 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 5 Jan 2018 04:48:38 +0000 (13:48 +0900)
Change-Id: Iebaede363ab6667f453f5c6d9855a12171853b1d
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
inc/w-input-selector.h
src/w-input-keyboard.cpp

index 7ff2ed2..cedcf17 100755 (executable)
@@ -44,6 +44,9 @@
 #include <Elementary.h>
 #include <Evas.h>
 #include <efl_extension.h>
+#include <string>
+
+using namespace std;
 
 enum {
        APP_TYPE_SELECT_MODE = 1,
@@ -114,9 +117,9 @@ typedef enum
 
 struct _InputKeyboardData
 {
-       char *guide_text;
-       char *default_text;
-       char *return_key_type;
+       string guide_text;
+       string default_text;
+       string return_key_type;
        int max_text_length;
        int cursor_position_set;
 };
index 5e9ae09..4e80c6c 100755 (executable)
@@ -34,7 +34,7 @@ bool input_keyboard_init(app_control_h app_control)
        int ret = -1;
        char *default_text = NULL;
        char *guide_text = NULL;
-       char *return_key_type = _("IDS_AMEMO_BUTTON_SEND");
+       char *return_key_type = NULL;
        char *max_text_length = NULL;
        char *cursor_position_set = NULL;
 
@@ -42,25 +42,38 @@ bool input_keyboard_init(app_control_h app_control)
 
        ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_DEFAULT_TEXT, &default_text);
        if (ret == APP_CONTROL_ERROR_NONE) {
-               g_input_keyboard_data.default_text = default_text;
+               if (default_text) {
+                       g_input_keyboard_data.default_text = string(default_text);
+                       free(default_text);
+               }
        }
        ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_INPUT_GUIDE_TEXT, &guide_text);
        if (ret == APP_CONTROL_ERROR_NONE) {
-               g_input_keyboard_data.guide_text = guide_text;
+               if (guide_text) {
+                       g_input_keyboard_data.guide_text = string(guide_text);
+                       free(guide_text);
+               }
        }
        ret = app_control_get_extra_data(app_control, "return_key_type", &return_key_type);
        if (ret == APP_CONTROL_ERROR_NONE) {
-               g_input_keyboard_data.return_key_type = return_key_type;
+               if (return_key_type) {
+                       g_input_keyboard_data.return_key_type = string(return_key_type);
+                       free(return_key_type);
+               }
        }
        ret = app_control_get_extra_data(app_control, "max_text_length", &max_text_length);
        if (ret == APP_CONTROL_ERROR_NONE) {
-               g_input_keyboard_data.max_text_length = atoi(max_text_length);
-               free(max_text_length);
+               if (max_text_length) {
+                       g_input_keyboard_data.max_text_length = atoi(max_text_length);
+                       free(max_text_length);
+               }
        }
        ret = app_control_get_extra_data(app_control, "cursor_position_set", &cursor_position_set);
        if (ret == APP_CONTROL_ERROR_NONE) {
-               g_input_keyboard_data.cursor_position_set = atoi(cursor_position_set);
-               free(cursor_position_set);
+               if (cursor_position_set) {
+                       g_input_keyboard_data.cursor_position_set = atoi(cursor_position_set);
+                       free(cursor_position_set);
+               }
        }
 
        return true;
@@ -68,18 +81,7 @@ bool input_keyboard_init(app_control_h app_control)
 
 void input_keyboard_deinit(void)
 {
-       if (g_input_keyboard_data.guide_text)
-               free(g_input_keyboard_data.guide_text);
-
-       if (g_input_keyboard_data.default_text)
-               free(g_input_keyboard_data.default_text);
-
-       if (g_input_keyboard_data.return_key_type)
-               free(g_input_keyboard_data.return_key_type);
-
-       g_input_keyboard_data.default_text = NULL;
-       g_input_keyboard_data.guide_text = NULL;
-       g_input_keyboard_data.return_key_type = _("IDS_AMEMO_BUTTON_SEND");
+       g_input_keyboard_data.return_key_type = string(_("IDS_AMEMO_BUTTON_SEND"));
        g_input_keyboard_data.max_text_length = KEYBOARD_EDITOR_CHAR_COUNT_MAX;
        g_input_keyboard_data.cursor_position_set = 0;
 
@@ -168,12 +170,12 @@ void create_fullscreen_editor(void *data)
        elm_entry_single_line_set(entry, EINA_TRUE);
        elm_entry_scrollable_set(entry, EINA_TRUE);
        elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-       elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text);
-       elm_entry_entry_set(entry, g_input_keyboard_data.default_text);
+       elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text.c_str());
+       elm_entry_entry_set(entry, g_input_keyboard_data.default_text.c_str());
        elm_entry_cursor_end_set(entry);
        evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       if (g_input_keyboard_data.return_key_type && strcmp(g_input_keyboard_data.return_key_type, "DONE") == 0) {
+       if (g_input_keyboard_data.return_key_type == string("DONE")) {
                elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
                evas_object_smart_callback_add(entry, "activated", enter_keydown_cb, ad);
        }
@@ -184,7 +186,7 @@ void create_fullscreen_editor(void *data)
        elm_box_pack_end(box, entry);
 
        Evas_Object *btn = elm_button_add(box);
-       elm_object_text_set(btn, g_input_keyboard_data.return_key_type);
+       elm_object_text_set(btn, g_input_keyboard_data.return_key_type.c_str());
        evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.5);
        evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_smart_callback_add(btn, "clicked", btn_clicked_cb, NULL);
@@ -234,12 +236,12 @@ static Evas_Object *create_multiline_editfield_layout(Evas_Object *parent, void
 
        elm_entry_scrollable_set(entry, EINA_TRUE);
        elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-       elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text);
-       elm_entry_entry_set(entry, g_input_keyboard_data.default_text);
+       elm_object_part_text_set(entry, "elm.guide", g_input_keyboard_data.guide_text.c_str());
+       elm_entry_entry_set(entry, g_input_keyboard_data.default_text.c_str());
        elm_entry_cursor_end_set(entry);
        evas_object_smart_callback_add(entry, "focused", editfield_focused_cb, editfield);
        evas_object_smart_callback_add(entry, "unfocused", editfield_unfocused_cb, editfield);
-       if (g_input_keyboard_data.return_key_type && strcmp(g_input_keyboard_data.return_key_type, "DONE") == 0) {
+       if (g_input_keyboard_data.return_key_type == string("DONE")) {
                elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
                evas_object_smart_callback_add(entry, "activated", enter_keydown_cb, ad);
        }