Fix memory leak issue
[platform/core/uifw/inputdelegator.git] / src / w-input-selector.cpp
index 077136f..f9c1243 100755 (executable)
@@ -43,6 +43,8 @@ InputKeyboardData g_input_keyboard_data;
 InputTypeData g_input_type_data;
 InputTemplateData g_input_template_data;
 
+static bool g_set_mimetype_in_app_service = false;
+static bool g_set_mimetype_in_app_resume = false;
 
 static Elm_Object_Item *it_empty;
 static Elm_Object_Item *it_title;
@@ -156,7 +158,6 @@ void init_customizing_theme(void)
        elm_theme_extension_add(NULL, app_edj_path.c_str());
 }
 
-
 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
 {
        reply_to_sender_by_callback_for_back();
@@ -1018,8 +1019,10 @@ unsigned int _update_smartreply_items(void *user_data)
                                }
                        }
 
-                       if (matched == true)
+                       if (matched == true) {
+                               free(reply);
                                continue;
+                       }
 
                        elm_genlist_item_append(app_data->genlist,
                                                itc,
@@ -1030,8 +1033,10 @@ unsigned int _update_smartreply_items(void *user_data)
                                                app_data);
 
                        item_size++;
-                       if (item_size >= 3)
+                       free(reply);
+                       if (item_size >= 3) {
                                break;
+                       }
                }
                elm_genlist_item_class_free(itc);
        }
@@ -1117,7 +1122,7 @@ unsigned int _update_template_items(void *user_data)
                elm_genlist_item_class_free(itc);
 
                // drawing button (+)
-               if (app_data->mime_type == MIME_TYPE_ALL) {
+               if (app_data->mime_type == MIME_TYPE_ALL && app_data->app_type == APP_TYPE_SELECT_MODE) {
                        Elm_Genlist_Item_Class *itc;
                        itc = elm_genlist_item_class_new();
 
@@ -1344,6 +1349,8 @@ void _app_service(app_control_h service, void* user_data)
        g_input_template_data.input_template_array = user_template_array;
        g_input_template_data.input_template_array_len = user_template_array_len;
 
+       g_set_mimetype_in_app_service = false;
+
        ret = app_control_get_mime(service, &mime_type);
        if (ret != APP_CONTROL_ERROR_NONE) {
                LOGD("Fail to get mime type : %d", ret);
@@ -1353,6 +1360,7 @@ void _app_service(app_control_h service, void* user_data)
                        if (!strncmp(mime_type, "image/", strlen("image/"))) {
                                app_data->mime_type = MIME_TYPE_IMAGE;
                                app_data->app_type = APP_TYPE_DRAWING;
+                               g_set_mimetype_in_app_service = true;
                                launch_drawing_app((void *)app_data);
                                if (mime_type)
                                        free(mime_type);
@@ -1437,7 +1445,6 @@ ACTIVATE :
                free(context);
 }
 
-
 void _app_pause(void* user_data)
 {
        PRINTFUNC(DLOG_DEBUG, "");
@@ -1448,6 +1455,16 @@ void _app_resume(void* user_data)
 {
        PRINTFUNC(DLOG_DEBUG, "");
        resume_voice();
+
+       if (g_set_mimetype_in_app_resume) {
+               app_control_destroy(app_data->source_app_control);
+               app_data->source_app_control = NULL;
+               ui_app_exit();
+       }
+
+       if (g_set_mimetype_in_app_service) {
+               g_set_mimetype_in_app_resume = true;
+       }
 }
 
 void _app_terminate(void* user_data)