From: Jihoon Kim Date: Fri, 30 Jul 2010 05:31:03 +0000 (+0900) Subject: [ecore_imf] fix memory leak when private key or disable key func is used X-Git-Tag: accepted/2.0/20130306.224007~345 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8311c53be52cc7b246f26b9446e058069c82983;p=profile%2Fivi%2Fecore.git [ecore_imf] fix memory leak when private key or disable key func is used --- diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h index d3501e6..2adea4d 100644 --- a/src/lib/ecore_imf/Ecore_IMF.h +++ b/src/lib/ecore_imf/Ecore_IMF.h @@ -461,8 +461,8 @@ extern "C" { int (*input_panel_imdata_set) (Ecore_IMF_Context *ctx, const char* data, int len); int (*input_panel_imdata_get) (Ecore_IMF_Context *ctx, char* data, int *len); - int (*input_panel_style_set) (Ecore_IMF_Context *ctx, ISE_STYLE style); - int (*input_panel_style_get) (Ecore_IMF_Context *ctx, ISE_STYLE *style); + int (*input_panel_style_set) (Ecore_IMF_Context *ctx, ISE_STYLE style); /* will de deprecated */ + int (*input_panel_style_get) (Ecore_IMF_Context *ctx, ISE_STYLE *style); /* will de deprecated */ int (*input_panel_geometry_get) (Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h); int (*input_panel_private_key_set) (Ecore_IMF_Context *ctx, int layout_index, int key_index, const char *img_path, const char* label, const char* value); int (*input_panel_private_key_image_set) (Ecore_IMF_Context *ctx, int layout_index, int key_index, const char *img_path, const char* value); /* will be deprecated */ @@ -479,13 +479,13 @@ extern "C" { Ecore_IMF_Input_Panel_State (*input_panel_state_get) (Ecore_IMF_Context *ctx); /* CallBack APIs */ - void (*ise_state_add_listener) (Ecore_IMF_Context *ctx, void (*plistenerCallBackFunc) (ISE_EVENT,int), void *data); /* This API will be depricated */ - void (*ise_state_remove_listener)(Ecore_IMF_Context *ctx, int listener_id); /* This API will be depricated */ + void (*ise_state_add_listener) (Ecore_IMF_Context *ctx, void (*plistenerCallBackFunc) (ISE_EVENT,int), void *data); /* will be depricated */ + void (*ise_state_remove_listener)(Ecore_IMF_Context *ctx, int listener_id); /* will be depricated */ void (*ise_state_change_listener)(Ecore_IMF_Context *ctx, void (*plistenerCallBackFunc) (ISE_EVENT,int)); /* This API will be depricated */ void (*input_panel_event_callback_set) (Ecore_IMF_Context *ctx, void (*plistenerCallBackFunc) (void *, ISE_EVENT, int), void *data); /* will be deprecated */ - int (*input_panel_initialize)(Ecore_IMF_Context *ctx, Evas_Object * mainwindow); - const char * (*get_focused_preedit_string)(Ecore_IMF_Context *ctx); + int (*input_panel_initialize)(Ecore_IMF_Context *ctx, Evas_Object * mainwindow); /* will be depricated */ + const char * (*get_focused_preedit_string)(Ecore_IMF_Context *ctx); /* will be depricated */ void (*input_panel_key_disabled_set) (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled); @@ -495,7 +495,7 @@ extern "C" { void (*input_panel_move) (Ecore_IMF_Context *ctx, int x, int y); - void (*input_panel_event_callback_add) (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value), void *data); + void (*input_panel_event_callback_add) (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value), const void *data); void (*input_panel_event_callback_del) (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallbackFunc) (void *data, Ecore_IMF_Context *ctx, int value)); }; @@ -525,6 +525,7 @@ extern "C" { EAPI void ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window); EAPI void* ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas); + EAPI void* ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx); EINA_DEPRECATED EAPI void ecore_imf_context_show(Ecore_IMF_Context *ctx); EINA_DEPRECATED EAPI void ecore_imf_context_hide(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos); diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c index ffa3d1f..76adbb7 100644 --- a/src/lib/ecore_imf/ecore_imf_context.c +++ b/src/lib/ecore_imf/ecore_imf_context.c @@ -216,6 +216,8 @@ ecore_imf_context_info_get(Ecore_IMF_Context *ctx) EAPI void ecore_imf_context_del(Ecore_IMF_Context *ctx) { + void *data; + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, @@ -224,17 +226,17 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx) } if (ctx->klass->del) ctx->klass->del(ctx); ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); - -/* - void *data; EINA_LIST_FREE(ctx->private_key_list, data) free(data); EINA_LIST_FREE(ctx->disabled_key_list, data) free(data); -*/ - free(ctx); + + ctx->private_key_list = NULL; + ctx->disabled_key_list = NULL; + + free(ctx); } /** @@ -296,8 +298,22 @@ ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas) return; } if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas); + ctx->client_canvas = canvas; +} + +EAPI void* +ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx) +{ + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_client_canvas_get"); + return NULL; + } + return ctx->client_canvas; } + /** * Ask the Input Method Context to show itself. * @@ -1140,7 +1156,7 @@ ecore_imf_context_input_panel_private_key_list_get (Ecore_IMF_Context *ctx) if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_list_get"); - return; + return NULL; } return ctx->private_key_list; diff --git a/src/lib/ecore_imf/ecore_imf_private.h b/src/lib/ecore_imf/ecore_imf_private.h index 5965b39..6d8931d 100644 --- a/src/lib/ecore_imf/ecore_imf_private.h +++ b/src/lib/ecore_imf/ecore_imf_private.h @@ -44,7 +44,7 @@ struct _Ecore_IMF_Context void *data; int input_mode; void* window; - void* client_object; + void* client_canvas; Ecore_IMF_Input_Panel_Layout input_panel_layout; int use_effect; int input_panel_x;