mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
chore(init): release indev and display automatically (#4793)
Signed-off-by: XiaoweiYan <yanxiaowei@xiaomi.com> Co-authored-by: XiaoweiYan <yanxiaowei@xiaomi.com>
This commit is contained in:
parent
9a9830671f
commit
3f8d56d0be
@ -87,6 +87,17 @@ static inline void lv_global_init(lv_global_t * global)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void _lv_cleanup_devices(lv_global_t * global)
|
||||
{
|
||||
LV_ASSERT_NULL(global);
|
||||
|
||||
if(global) {
|
||||
/* cleanup indev and display */
|
||||
_lv_ll_clear_custom(&(global->indev_ll), (void (*)(void *)) lv_indev_delete);
|
||||
_lv_ll_clear_custom(&(global->disp_ll), (void (*)(void *)) lv_display_remove);
|
||||
}
|
||||
}
|
||||
|
||||
bool lv_is_initialized(void)
|
||||
{
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||
@ -274,7 +285,6 @@ void lv_deinit(void)
|
||||
LV_LOG_WARN("lv_deinit: already deinit!");
|
||||
return;
|
||||
}
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM || LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
_lv_sysmon_builtin_deinit();
|
||||
@ -282,6 +292,8 @@ void lv_deinit(void)
|
||||
|
||||
lv_display_set_default(NULL);
|
||||
|
||||
_lv_cleanup_devices(LV_GLOBAL_DEFAULT());
|
||||
|
||||
#if LV_USE_SPAN != 0
|
||||
lv_span_stack_deinit();
|
||||
#endif
|
||||
@ -350,15 +362,14 @@ void lv_deinit(void)
|
||||
|
||||
lv_mem_deinit();
|
||||
|
||||
lv_initialized = false;
|
||||
|
||||
LV_LOG_INFO("lv_deinit done");
|
||||
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(NULL);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
lv_initialized = false;
|
||||
|
||||
LV_LOG_INFO("lv_deinit done");
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -188,7 +188,7 @@ void _lv_ll_remove(lv_ll_t * ll_p, void * node_p)
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void _lv_ll_clear(lv_ll_t * ll_p)
|
||||
void _lv_ll_clear_custom(lv_ll_t * ll_p, void(*cleanup)(void *))
|
||||
{
|
||||
void * i;
|
||||
void * i_next;
|
||||
@ -198,10 +198,13 @@ void _lv_ll_clear(lv_ll_t * ll_p)
|
||||
|
||||
while(i != NULL) {
|
||||
i_next = _lv_ll_get_next(ll_p, i);
|
||||
|
||||
_lv_ll_remove(ll_p, i);
|
||||
lv_free(i);
|
||||
|
||||
if(cleanup == NULL) {
|
||||
_lv_ll_remove(ll_p, i);
|
||||
lv_free(i);
|
||||
}
|
||||
else {
|
||||
cleanup(i);
|
||||
}
|
||||
i = i_next;
|
||||
}
|
||||
}
|
||||
|
@ -76,11 +76,16 @@ void * _lv_ll_ins_tail(lv_ll_t * ll_p);
|
||||
*/
|
||||
void _lv_ll_remove(lv_ll_t * ll_p, void * node_p);
|
||||
|
||||
void _lv_ll_clear_custom(lv_ll_t * ll_p, void(*cleanup)(void *));
|
||||
|
||||
/**
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void _lv_ll_clear(lv_ll_t * ll_p);
|
||||
static inline void _lv_ll_clear(lv_ll_t * ll_p)
|
||||
{
|
||||
return _lv_ll_clear_custom(ll_p, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a node to a new linked list
|
||||
|
Loading…
x
Reference in New Issue
Block a user