1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(theme): fix crash in lv_theme_basic_init

This commit is contained in:
Gabor Kiss-Vamosi 2022-01-19 13:02:55 +01:00
parent 933d67fe5b
commit ca5f04cfe3
2 changed files with 7 additions and 6 deletions

View File

@ -16,9 +16,9 @@
/*********************
* DEFINES
*********************/
#define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 3)
#define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4)
#define COLOR_WHITE lv_color_white()
#define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 1)
#define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 2)
#define COLOR_DARK lv_palette_main(LV_PALETTE_GREY)
#define COLOR_DIM lv_palette_darken(LV_PALETTE_GREY, 2)
#define SCROLLBAR_WIDTH 2
@ -122,7 +122,7 @@ static void style_init(void)
bool lv_theme_basic_is_inited(void)
{
return LV_GC_ROOT(_lv_theme_default_styles) == NULL ? false : true;
return LV_GC_ROOT(_lv_theme_basic_styles) == NULL ? false : true;
}
lv_theme_t * lv_theme_basic_init(lv_disp_t * disp)
@ -133,8 +133,8 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp)
*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);
LV_GC_ROOT(_lv_theme_basic_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_basic_styles);
}
theme.disp = disp;
@ -257,7 +257,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_SWITCH
else if(lv_obj_check_type(obj, &lv_switch_class)) {
lv_obj_add_style(obj, &styles->light, 0);
lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR);
lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_add_style(obj, &styles->dim, LV_PART_KNOB);
}
#endif

View File

@ -57,6 +57,7 @@ extern "C" {
LV_DISPATCH_COND(f, _lv_draw_mask_radius_circle_dsc_arr_t , _lv_circle_cache, LV_DRAW_COMPLEX, 1) \
LV_DISPATCH_COND(f, _lv_draw_mask_saved_arr_t , _lv_draw_mask_list, LV_DRAW_COMPLEX, 1) \
LV_DISPATCH(f, void * , _lv_theme_default_styles) \
LV_DISPATCH(f, void * , _lv_theme_basic_styles) \
LV_DISPATCH_COND(f, uint8_t *, _lv_font_decompr_buf, LV_USE_FONT_COMPRESSED, 1) \
LV_DISPATCH(f, uint8_t * , _lv_grad_cache_mem)