fix(disp) fix memory leak in lv_disp_remove (#2355)

Co-authored-by: wangxuedong <wangxuedong@xiaomi.com>
This commit is contained in:
xaowang96
2021-07-07 19:05:12 +08:00
committed by GitHub
parent e53aa82658
commit ab7e0eb2b6
+14
View File
@@ -220,6 +220,20 @@ void lv_disp_remove(lv_disp_t * disp)
_lv_ll_remove(&LV_GC_ROOT(_lv_disp_ll), disp);
lv_timer_del(disp->refr_timer);
/** delete screen and other obj */
if (disp->sys_layer) {
lv_obj_del(disp->sys_layer);
disp->sys_layer = NULL;
}
if (disp->top_layer) {
lv_obj_del(disp->top_layer);
disp->top_layer = NULL;
}
while (disp->screen_cnt != 0) {
/*Delete the screenst*/
lv_obj_del(disp->screens[0]);
}
lv_mem_free(disp);
if(was_default) lv_disp_set_default(_lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)));