fix memory corruptions due to animation audates

This commit is contained in:
Gabor Kiss-Vamosi
2019-04-22 09:20:04 +02:00
parent e2cfba7c9f
commit 56fcd2d151
3 changed files with 10 additions and 9 deletions

View File

@@ -422,16 +422,17 @@ static bool anim_ready_handler(lv_anim_t * a)
* - no repeat, play back is enabled and play back is ready */ * - no repeat, play back is enabled and play back is ready */
if((a->repeat == 0 && a->playback == 0) || if((a->repeat == 0 && a->playback == 0) ||
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) { (a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
lv_anim_ready_cb_t ready_cb = a->ready_cb;
void * p = a->var; /*Create copy from the animation and delete the animation from the list.
* This way the `ready_cb` will see the animations like it's animation is ready deleted*/
lv_anim_t a_tmp;
memcpy(&a_tmp, a, sizeof(lv_anim_t));
lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a); lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a); lv_mem_free(a);
anim_list_changed = true; anim_list_changed = true;
/* Call the callback function at the end*/ /* Call the callback function at the end*/
/* Check if an animation is deleted in the cb function if(a_tmp.ready_cb != NULL) a_tmp.ready_cb(&a_tmp);
* if yes then the caller function has to know this*/
if(ready_cb != NULL) ready_cb(p);
} }
/*If the animation is not deleted then restart it*/ /*If the animation is not deleted then restart it*/
else { else {

View File

@@ -19,7 +19,7 @@
* DEFINES * DEFINES
*********************/ *********************/
/*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 #define LV_MEM_ADD_JUNK 1
#ifdef LV_MEM_ENV64 #ifdef LV_MEM_ENV64
#define MEM_UNIT uint64_t #define MEM_UNIT uint64_t

View File

@@ -768,11 +768,11 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
lv_fit_t fit_left = lv_page_get_scrl_fit_left(page);
lv_fit_t fit_top = lv_page_get_scrl_fit_top(page);
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
lv_obj_t * child; lv_obj_t * child;
if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/ if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
lv_fit_t fit_left = lv_page_get_scrl_fit_left(page);
lv_fit_t fit_top = lv_page_get_scrl_fit_top(page);
child = lv_obj_get_child(page, NULL); child = lv_obj_get_child(page, NULL);
while(child != NULL) { while(child != NULL) {
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) { if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {