From 19d17b399095dd13a79c7ad801b40733043b3158 Mon Sep 17 00:00:00 2001 From: Thiep Ha Date: Sat, 27 Apr 2013 09:00:31 +0900 Subject: [PATCH] [CopyPaste,Entry] Add checking to avoid application crash Change-Id: I941c5a7f267fbc2d3a1384fa776036ed4538170e --- src/modules/ctxpopup_copypasteUI/copypaste.c | 31 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/modules/ctxpopup_copypasteUI/copypaste.c b/src/modules/ctxpopup_copypasteUI/copypaste.c index cc89525..a3f01b2 100644 --- a/src/modules/ctxpopup_copypasteUI/copypaste.c +++ b/src/modules/ctxpopup_copypasteUI/copypaste.c @@ -82,7 +82,9 @@ _remove_tags(const char *str) static void _entry_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + _ctxpopup_hide(data); evas_object_del(data); + data = NULL; } static void @@ -271,7 +273,7 @@ _ctxpopup_position(Evas_Object *obj __UNUSED__) static void _select_all(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->selectall(data,obj,event_info); _ctxpopup_hide(obj); @@ -280,7 +282,7 @@ _select_all(void *data, Evas_Object *obj, void *event_info) static void _select(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->select(data,obj,event_info); _ctxpopup_hide(obj); @@ -289,7 +291,7 @@ _select(void *data, Evas_Object *obj, void *event_info) static void _paste(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->paste(data,obj,event_info); _ctxpopup_hide(obj); @@ -298,7 +300,7 @@ _paste(void *data, Evas_Object *obj, void *event_info) static void _cut(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->cut(data,obj,event_info); _ctxpopup_hide(obj); @@ -309,7 +311,7 @@ _cut(void *data, Evas_Object *obj, void *event_info) static void _copy(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->copy(data,obj,event_info); _ctxpopup_hide(obj); @@ -320,7 +322,7 @@ _copy(void *data, Evas_Object *obj, void *event_info) static void _cancel(void *data, Evas_Object *obj, void *event_info) { - if(!ext_mod) return; + if((!ext_mod) || (!data)) return; ext_mod->cancel(data,obj,event_info); _ctxpopup_hide(obj); @@ -427,6 +429,7 @@ obj_hook(Evas_Object *obj) if(!ext_mod) { ext_mod = ELM_NEW(Elm_Entry_Extension_data); + if (!ext_mod) return; elm_entry_extension_module_data_get(obj,ext_mod); } } @@ -439,6 +442,11 @@ obj_unhook(Evas_Object *obj) if(ext_mod) { + if (ext_mod->popup) + { + evas_object_del(ext_mod->popup); + ext_mod->popup = NULL; + } free(ext_mod); ext_mod = NULL; } @@ -464,7 +472,11 @@ obj_longpress(Evas_Object *obj) #ifdef HAVE_ELEMENTARY_X int cbhm_count = _cbhm_item_count_get(obj); #endif - if (ext_mod->popup) evas_object_del(ext_mod->popup); + if (ext_mod->popup) + { + evas_object_del(ext_mod->popup); + ext_mod->popup = NULL; + } //else elm_widget_scroll_freeze_push(obj); top = elm_widget_top_get(obj); if(top) @@ -475,6 +487,11 @@ obj_longpress(Evas_Object *obj) evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _entry_del_cb, ext_mod->popup); evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _entry_hide_cb, ext_mod->popup); } + else + { + ext_mod->caller = NULL; + return; + } elm_object_style_set(ext_mod->popup,"copypaste"); context_menu_orientation = edje_object_data_get -- 2.7.4