From e8fdac41a96f052e7cb557dd9dce0d24292af123 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 13 Mar 2019 22:15:08 +0100 Subject: [PATCH] lv_group_add_obj: do not add teh object if already added to this group --- lv_core/lv_group.c | 11 ++++++++++- lv_objx/lv_btn.c | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index f86c6adae..ed670229c 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -119,12 +119,21 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj) { if(group == NULL) return; + /*Do not add the object twice*/ + lv_obj_t ** obj_i; + LV_LL_READ(group->obj_ll, obj_i) { + if((*obj_i) == obj) { + LV_LOG_INFO("lv_group_add_obj: the object is already added to this group"); + return; + } + } + /*If the object is already in a group and focused then defocus it*/ if(obj->group_p) { if(lv_obj_is_focused(obj)) { lv_group_refocus(obj->group_p); - LV_LOG_INFO("group: assign object to an other group"); + LV_LOG_INFO("lv_group_add_obj: assign object to an other group"); } } diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index b8dafb56c..cc21209b4 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -493,7 +493,6 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode */ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) { - lv_res_t res; /* Include the ancient signal function */ @@ -501,7 +500,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); - lv_btn_state_t state = lv_btn_get_state(btn); bool tgl = lv_btn_get_toggle(btn); if(sign == LV_SIGNAL_PRESSED) {