Skip to content

Commit

Permalink
gen_mpy: Add checks in mp_lv_deinit_gc().
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-anl committed Nov 11, 2024
1 parent bbeb338 commit 14cfb06
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions gen/gen_mpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,16 +1128,21 @@ def register_int_ptr_type(convertor, *types):
void mp_lv_deinit_gc()
{
// mp_printf(&mp_plat_print, "[ DEINIT GC ]");
mp_lv_roots = MP_STATE_VM(mp_lv_roots) = NULL;
mp_lv_user_data = MP_STATE_VM(mp_lv_user_data) = NULL;
mp_lv_roots_initialized = MP_STATE_VM(mp_lv_roots_initialized) = 0;
lvgl_mod_initialized = MP_STATE_VM(lvgl_mod_initialized) = 0;
if (MP_STATE_VM(mp_lv_roots_initialized)) {
// mp_printf(&mp_plat_print, "[ DEINIT GC ]");
mp_lv_roots = MP_STATE_VM(mp_lv_roots) = NULL;
mp_lv_user_data = MP_STATE_VM(mp_lv_user_data) = NULL;
mp_lv_roots_initialized = MP_STATE_VM(mp_lv_roots_initialized) = 0;
lvgl_mod_initialized = MP_STATE_VM(lvgl_mod_initialized) = 0;
}
}
static mp_obj_t lvgl_mod___init__(void) {
#if !MICROPY_MODULE_BUILTIN_INIT
#error MICROPY_MODULE_BUILTIN_INIT required to be set in build.
#endif
static mp_obj_t lvgl_mod___init__(void)
{
if (!MP_STATE_VM(lvgl_mod_initialized)) {
// __init__ for builtins is called each time the module is imported,
// so ensure that initialisation only happens once.
Expand All @@ -1154,8 +1159,8 @@ def register_int_ptr_type(convertor, *types):
}
static MP_DEFINE_CONST_FUN_OBJ_0(lvgl_mod___init___obj, lvgl_mod___init__);
static mp_obj_t lvgl_mod___del__(void) {
static mp_obj_t lvgl_mod___del__(void)
{
if (MP_STATE_VM(lvgl_mod_initialized)) {
#ifdef LV_PORT_INDEV_DEINIT
LV_PORT_INDEV_DEINIT();
Expand Down

0 comments on commit 14cfb06

Please sign in to comment.