mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-30 23:51:54 +08:00
fix(theme): fix theme initialization issue introduced in 6e0072479
This commit is contained in:
@@ -50,6 +50,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
|
|||||||
**********************/
|
**********************/
|
||||||
static my_theme_styles_t * styles;
|
static my_theme_styles_t * styles;
|
||||||
static lv_theme_t theme;
|
static lv_theme_t theme;
|
||||||
|
static bool inited;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* 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)
|
*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*/
|
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
|
||||||
if(!lv_theme_basic_is_inited()) {
|
if(!lv_theme_basic_is_inited()) {
|
||||||
|
inited = false;
|
||||||
LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
|
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);
|
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);
|
lv_obj_report_style_change(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
|
||||||
return (lv_theme_t *)&theme;
|
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)
|
static void style_init_reset(lv_style_t * style)
|
||||||
{
|
{
|
||||||
if(lv_theme_basic_is_inited()) {
|
if(inited) {
|
||||||
lv_style_reset(style);
|
lv_style_reset(style);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ static lv_color_t color_scr;
|
|||||||
static lv_color_t color_text;
|
static lv_color_t color_text;
|
||||||
static lv_color_t color_card;
|
static lv_color_t color_card;
|
||||||
static lv_color_t color_grey;
|
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)
|
*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*/
|
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
|
||||||
if(!lv_theme_default_is_inited()) {
|
if(!lv_theme_default_is_inited()) {
|
||||||
|
inited = false;
|
||||||
LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
|
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);
|
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);
|
if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL);
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
|
||||||
return (lv_theme_t *)&theme;
|
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)
|
static void style_init_reset(lv_style_t * style)
|
||||||
{
|
{
|
||||||
if(lv_theme_default_is_inited()) {
|
if(inited) {
|
||||||
lv_style_reset(style);
|
lv_style_reset(style);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
|
|||||||
**********************/
|
**********************/
|
||||||
static my_theme_styles_t * styles;
|
static my_theme_styles_t * styles;
|
||||||
static lv_theme_t theme;
|
static lv_theme_t theme;
|
||||||
|
static bool inited;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* 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)
|
*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*/
|
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
|
||||||
if(!lv_theme_mono_is_inited()) {
|
if(!lv_theme_mono_is_inited()) {
|
||||||
|
inited = false;
|
||||||
LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
|
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);
|
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);
|
if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL);
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
|
||||||
return (lv_theme_t *)&theme;
|
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)
|
static void style_init_reset(lv_style_t * style)
|
||||||
{
|
{
|
||||||
if(lv_theme_mono_is_inited()) {
|
if(inited) {
|
||||||
lv_style_reset(style);
|
lv_style_reset(style);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user