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

fix(leak): fix memory leak on music list (#4732)

Signed-off-by: YanXiaowei <yanxiaowei@xiaomi.com>
Co-authored-by: YanXiaowei <yanxiaowei@xiaomi.com>
This commit is contained in:
bjsylvia 2023-11-02 16:33:39 +08:00 committed by GitHub
parent 9e252bdff7
commit cafc8393a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@
**********************/
static lv_obj_t * add_list_button(lv_obj_t * parent, uint32_t track_id);
static void btn_click_event_cb(lv_event_t * e);
static void list_delete_event_cb(lv_event_t * e);
/**********************
* STATIC VARIABLES
@ -129,6 +130,7 @@ lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
/*Create an empty transparent container*/
list = lv_obj_create(parent);
lv_obj_add_event(list, list_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_remove_style_all(list);
lv_obj_set_size(list, LV_HOR_RES, LV_VER_RES - LV_DEMO_MUSIC_HANDLE_SIZE);
lv_obj_set_y(list, LV_DEMO_MUSIC_HANDLE_SIZE);
@ -233,5 +235,21 @@ static void btn_click_event_cb(lv_event_t * e)
_lv_demo_music_play(idx);
}
static void list_delete_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_DELETE) {
lv_style_reset(&style_scrollbar);
lv_style_reset(&style_btn);
lv_style_reset(&style_button_pr);
lv_style_reset(&style_button_chk);
lv_style_reset(&style_button_dis);
lv_style_reset(&style_title);
lv_style_reset(&style_artist);
lv_style_reset(&style_time);
}
}
#endif /*LV_USE_DEMO_MUSIC*/