Skip to content

Commit

Permalink
fix(theme): fix theme initialization issue introduced in 6e00724
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Dec 20, 2021
1 parent fa9340c commit d231644
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/extra/themes/basic/lv_theme_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/extra/themes/default/lv_theme_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**********************
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/extra/themes/mono/lv_theme_mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d231644

Please sign in to comment.