fix(theme): fix theme initialization issue introduced in 6e0072479

This commit is contained in:
Gabor Kiss-Vamosi
2021-12-20 15:29:07 +01:00
parent fa9340c45f
commit d2316447c5
3 changed files with 15 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {