diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 6d47a716d5..3d4661bf01 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -1920,6 +1920,14 @@ static void delete_children(lv_obj_t * obj) lv_obj_t * i; lv_obj_t * i_next; i = lv_ll_get_head(&(obj->child_ll)); + + /*Remove from the group; remove before transversing children so that + * the object still has access to all children during the + * LV_SIGNAL_DEFOCUS call*/ +#if USE_LV_GROUP + if(obj->group_p != NULL) lv_group_remove_obj(obj); +#endif + while(i != NULL) { /*Get the next object before delete this*/ i_next = lv_ll_get_next(&(obj->child_ll), i); @@ -1936,10 +1944,6 @@ static void delete_children(lv_obj_t * obj) lv_anim_del(obj, NULL); #endif - /*Delete from the group*/ -#if USE_LV_GROUP - if(obj->group_p != NULL) lv_group_remove_obj(obj); -#endif /* Reset the input devices if * the currently pressed object is deleted*/