1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix(anim): fix reading deleted anaimations in lv_anim_del

see #4508
This commit is contained in:
Gabor Kiss-Vamosi 2023-09-14 17:22:08 +02:00
parent 140369c5c0
commit ca0fed9344

View File

@ -136,13 +136,9 @@ uint32_t lv_anim_get_playtime(lv_anim_t * a)
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
{
lv_anim_t * a;
lv_anim_t * a_next;
bool del = false;
a = _lv_ll_get_head(anim_ll_p);
while(a != NULL) {
/*'a' might be deleted, so get the next object while 'a' is valid*/
a_next = _lv_ll_get_next(anim_ll_p, a);
if((a->var == var || var == NULL) && (a->exec_cb == exec_cb || exec_cb == NULL)) {
_lv_ll_remove(anim_ll_p, a);
if(a->deleted_cb != NULL) a->deleted_cb(a);
@ -152,7 +148,9 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
del = true;
}
a = a_next;
/*Always start from the head on delete, because we don't know
*how `anim_ll_p` was changes in `a->deleted_cb` */
a = del ? _lv_ll_get_head(anim_ll_p) : _lv_ll_get_next(anim_ll_p, a);
}
return del;