1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(anim_timeline) avoid calling lv_anim_del(NULL, NULL) (#2628)

* add anim_timeline

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* add anim_timeline

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* add lv_anim_timeline.c to lv_misc.mk

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* LV_ANIM_TIMELINE_END uses global variables to replace macros, lv_anim_timeline_set_progress() adds user_data, act_time uses int32_t type

* solve the problem of uninitialized variable and act_time comparison

* add LV_ANIM_TIMELINE_CUSTOM_EXEC option

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* add LV_ANIM_TIMELINE_CUSTOM_EXEC in lv_conf_internal.h

* redesign lv_anim_timeline

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* add missing LV_USE_USER_DATA

* remove set_progress, update doc

* update workflow files

* Remove lv_example_anim_timeline_2.c and LV_ANIM_TIMELINE_CUSTOM_EXEC, update lv_anim_timeline_1.c example

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* fix warning

* fix(anim_timeline) heap use after free

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* fix(docs) wrong spelling of words in pictures

* perf(anim_timeline) add lv_anim_timeline_stop()

Signed-off-by: FASTSHIFT <vifextech@foxmail.com>

* fix(anim_timeline) avoid calling lv_anim_del(NULL, NULL)

Signed-off-by: _VIFEXTech <1290176185@qq.com>

* lv_anim_del replaces lv_anim_custom_del

* fix(anim_timeline) avoid calling when a->exec_cb is NULL

* fix(anim_timeline) add default var and virtual exec_cb

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
_VIFEXTech 2021-10-15 20:17:27 +08:00 committed by GitHub
parent 42989d4e9a
commit 6d15cb9698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ struct _lv_anim_timeline_t {
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_anim_timeline_virtual_exec_cb(void * var, int32_t v);
/**********************
* STATIC VARIABLES
@ -79,6 +80,12 @@ void lv_anim_timeline_add(lv_anim_timeline_t * at, uint32_t start_time, lv_anim_
at->anim_dsc[at->anim_dsc_cnt - 1].anim = *a;
at->anim_dsc[at->anim_dsc_cnt - 1].start_time = start_time;
/*Add default var and virtual exec_cb, used to delete animation.*/
if(a->var == NULL && a->exec_cb == NULL) {
at->anim_dsc[at->anim_dsc_cnt - 1].anim.var = at;
at->anim_dsc[at->anim_dsc_cnt - 1].anim.exec_cb = lv_anim_timeline_virtual_exec_cb;
}
}
uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at)
@ -114,7 +121,7 @@ void lv_anim_timeline_stop(lv_anim_timeline_t * at)
for(uint32_t i = 0; i < at->anim_dsc_cnt; i++) {
lv_anim_t * a = &(at->anim_dsc[i].anim);
lv_anim_custom_del(a, (lv_anim_custom_exec_cb_t)a->exec_cb);
lv_anim_del(a->var, a->exec_cb);
}
}
@ -133,6 +140,11 @@ void lv_anim_timeline_set_progress(lv_anim_timeline_t * at, uint16_t progress)
for(uint32_t i = 0; i < at->anim_dsc_cnt; i++) {
lv_anim_t * a = &(at->anim_dsc[i].anim);
if(a->exec_cb == NULL) {
continue;
}
uint32_t start_time = at->anim_dsc[i].start_time;
int32_t value = 0;
@ -171,3 +183,13 @@ bool lv_anim_timeline_get_reverse(lv_anim_timeline_t * at)
LV_ASSERT_NULL(at);
return at->reverse;
}
/**********************
* STATIC FUNCTIONS
**********************/
static void lv_anim_timeline_virtual_exec_cb(void * var, int32_t v)
{
LV_UNUSED(var);
LV_UNUSED(v);
}