diff --git a/src/extra/themes/basic/lv_theme_basic.c b/src/extra/themes/basic/lv_theme_basic.c index 8ff8627c8a..a68f10ab3f 100644 --- a/src/extra/themes/basic/lv_theme_basic.c +++ b/src/extra/themes/basic/lv_theme_basic.c @@ -50,6 +50,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj); **********************/ static my_theme_styles_t * styles; static lv_theme_t theme; +static bool inited; /********************** * MACROS @@ -131,6 +132,7 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp) *styles' data if LVGL is used in a binding (e.g. Micropython) *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ if(!lv_theme_basic_is_inited()) { + inited = false; LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); } @@ -147,6 +149,8 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp) lv_obj_report_style_change(NULL); } + inited = true; + return (lv_theme_t *)&theme; } @@ -379,7 +383,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(lv_theme_basic_is_inited()) { + if(inited) { lv_style_reset(style); } else { diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index eaf701c872..566343d9b1 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -177,6 +177,7 @@ static lv_color_t color_scr; static lv_color_t color_text; static lv_color_t color_card; static lv_color_t color_grey; +static bool inited = false; /********************** @@ -647,6 +648,7 @@ lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, l *styles' data if LVGL is used in a binding (e.g. Micropython) *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ if(!lv_theme_default_is_inited()) { + inited = false; LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); } @@ -668,6 +670,8 @@ lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, l if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + inited = true; + return (lv_theme_t *)&theme; } @@ -1160,7 +1164,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(lv_theme_default_is_inited()) { + if(inited) { lv_style_reset(style); } else { diff --git a/src/extra/themes/mono/lv_theme_mono.c b/src/extra/themes/mono/lv_theme_mono.c index af21e5054d..79d4383d86 100644 --- a/src/extra/themes/mono/lv_theme_mono.c +++ b/src/extra/themes/mono/lv_theme_mono.c @@ -64,6 +64,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj); **********************/ static my_theme_styles_t * styles; static lv_theme_t theme; +static bool inited; /********************** * MACROS @@ -175,6 +176,7 @@ lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t *styles' data if LVGL is used in a binding (e.g. Micropython) *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ if(!lv_theme_mono_is_inited()) { + inited = false; LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); } @@ -189,6 +191,8 @@ lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + inited = true; + return (lv_theme_t *)&theme; } @@ -489,7 +493,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(lv_theme_mono_is_inited()) { + if(inited) { lv_style_reset(style); } else {