From 6284e3a21bc8bc9f6938594633c61351a8860c3a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 12 Apr 2019 07:22:37 +0200 Subject: [PATCH] lv_list: check the return value of btn events --- src/lv_core/lv_obj.c | 12 +++++++----- src/lv_misc/lv_mem.c | 4 ++-- src/lv_objx/lv_list.c | 22 +++++++++++++--------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 1ff8c74ad..d3fd4de6d 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -345,9 +345,10 @@ lv_res_t lv_obj_del(lv_obj_t * obj) /*Delete from the group*/ #if LV_USE_GROUP bool was_focused = false; + lv_group_t * group = lv_obj_get_group(obj); - if(obj->group_p) { - if(lv_group_get_focused(obj->group_p) == obj) was_focused = true; + if(group) { + if(lv_group_get_focused(group) == obj) was_focused = true; lv_group_remove_obj(obj); } #endif @@ -390,7 +391,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj) } #if LV_USE_GROUP - if(was_focused) { + if(indev->group == group && was_focused) { lv_indev_reset(indev); } #endif @@ -2067,8 +2068,9 @@ static void delete_children(lv_obj_t * obj) * LV_SIGNAL_DEFOCUS call*/ #if LV_USE_GROUP bool was_focused = false; + lv_group_t * group = lv_obj_get_group(obj); - if(obj->group_p) { + if(group) { if(lv_group_get_focused(obj->group_p) == obj) was_focused = true; lv_group_remove_obj(obj); } @@ -2098,7 +2100,7 @@ static void delete_children(lv_obj_t * obj) lv_indev_reset(indev); } #if LV_USE_GROUP - if(was_focused) { + if(indev->group == group && was_focused) { lv_indev_reset(indev); } #endif diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index dd2ed2402..dca4a1ab6 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -18,8 +18,8 @@ /********************* * DEFINES *********************/ -#define LV_MEM_ADD_JUNK \ - 0 /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ +/*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ +#define LV_MEM_ADD_JUNK 0 #ifdef LV_MEM_ENV64 #define MEM_UNIT uint64_t diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index 883fd7c14..3f4de2b69 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -745,20 +745,24 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) * button*/ if(btn) { if(sign == LV_SIGNAL_PRESSED) { - lv_event_send(btn, LV_EVENT_PRESSED, NULL); + res = lv_event_send(btn, LV_EVENT_PRESSED, NULL); } else if(sign == LV_SIGNAL_PRESSING) { - lv_event_send(btn, LV_EVENT_PRESSING, NULL); + res = lv_event_send(btn, LV_EVENT_PRESSING, NULL); } else if(sign == LV_SIGNAL_LONG_PRESS) { - lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL); + res = lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL); } else if(sign == LV_SIGNAL_LONG_PRESS_REP) { - lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL); + res = lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL); } else if(sign == LV_SIGNAL_RELEASED) { ext->last_sel = btn; - if(indev->proc.long_pr_sent == 0) - lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL); - if(lv_indev_is_dragging(indev) == false) - lv_event_send(btn, LV_EVENT_CLICKED, NULL); - lv_event_send(btn, LV_EVENT_RELEASED, NULL); + if(indev->proc.long_pr_sent == 0) { + res = lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL); + } + if(lv_indev_is_dragging(indev) == false && res == LV_RES_OK) { + res = lv_event_send(btn, LV_EVENT_CLICKED, NULL); + } + if(res == LV_RES_OK) { + res = lv_event_send(btn, LV_EVENT_RELEASED, NULL); + } } } }