fix(theme): prevent reentrancy in resolution_change_event_cb (#10051)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build Docs / build-and-deploy (push) Has been cancelled
Build .deb packages / build (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (private) (push) Has been cancelled
Install LVGL using CMake / build-examples (public) (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Static Checks / Static Checks (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled

Co-authored-by: Jonas Petersson <jonaspetersson@spotify.com>
This commit is contained in:
Jonas Petersson
2026-05-25 14:05:43 +08:00
committed by GitHub
co-authored by Jonas Petersson
parent 62335dc753
commit d8ed8bc9e9
2 changed files with 34 additions and 8 deletions
+9 -8
View File
@@ -671,17 +671,19 @@ lv_theme_t * lv_theme_default_init(lv_display_t * disp, lv_color_t color_primary
theme->base.ext_data.data = NULL;
#endif
/*Remove the callback before triggering style refresh to prevent
*resolution_change_event_cb from re-entering lv_theme_default_init
*during lv_obj_report_style_change. Re-added below.*/
lv_display_remove_event_cb_with_user_data(new_disp, resolution_change_event_cb, theme);
style_init(theme);
theme->inited = true;
if(disp == NULL || lv_display_get_theme(disp) == (lv_theme_t *)theme) {
lv_obj_report_style_change(NULL);
}
theme->inited = true;
/*Re-initialize the styles if the resolution changes as a different display size might
*result in different paddings */
lv_display_remove_event_cb_with_user_data(new_disp, resolution_change_event_cb, theme);
lv_display_add_event_cb(new_disp, resolution_change_event_cb, LV_EVENT_RESOLUTION_CHANGED, theme);
return (lv_theme_t *) theme;
@@ -1239,9 +1241,8 @@ static void resolution_change_event_cb(lv_event_t * e)
lv_display_t * disp = lv_event_get_target(e);
my_theme_t * theme = lv_event_get_user_data(e);
lv_theme_default_init(disp, theme->base.color_primary, theme->base.color_secondary, theme->base.flags,
theme->base.font_normal);
lv_theme_default_init(disp, theme->base.color_primary, theme->base.color_secondary,
theme->base.flags & MODE_DARK, theme->base.font_normal);
}
#endif
+25
View File
@@ -148,6 +148,31 @@ static void test_widgets(const char * img_name)
lv_obj_clean(scr_act);
}
void test_theme_default_resolution_change_no_recursion(void)
{
lv_theme_t * theme = lv_theme_default_init(NULL,
lv_palette_main(LV_PALETTE_BLUE),
lv_palette_main(LV_PALETTE_RED),
true, LV_FONT_DEFAULT);
lv_display_set_theme(NULL, theme);
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Resolution change test");
lv_button_create(lv_screen_active());
lv_display_set_resolution(NULL, 320, 240);
TEST_ASSERT_NOT_NULL(lv_screen_active());
TEST_ASSERT_TRUE(lv_theme_default_is_inited());
lv_display_set_resolution(NULL, 800, 480);
TEST_ASSERT_NOT_NULL(lv_screen_active());
TEST_ASSERT_TRUE(lv_theme_default_is_inited());
lv_obj_clean(lv_screen_active());
}
void test_theme_default(void)
{
TEST_ASSERT_TRUE(lv_theme_default_is_inited());