From 84acb67dcae2728707dfd6ea5a5eadc8af17b282 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 2 Jul 2025 22:02:58 +0200 Subject: [PATCH] fix(xml): find constants in styles in the global scope --- src/others/xml/lv_xml_style.c | 18 ++++++++++++++++++ tests/src/test_assets/xml/view2.xml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/others/xml/lv_xml_style.c b/src/others/xml/lv_xml_style.c index ff7bf533b0..47c459924e 100644 --- a/src/others/xml/lv_xml_style.c +++ b/src/others/xml/lv_xml_style.c @@ -124,13 +124,31 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char * if(value[0] == '#') { const char * value_clean = &value[1]; + bool const_found = false; lv_xml_const_t * c; LV_LL_READ(&scope->const_ll, c) { if(lv_streq(c->name, value_clean)) { value = c->value; + const_found = true; break; } } + if(!const_found) { + lv_xml_component_scope_t * global_scope = lv_xml_component_get_scope("globals"); + if(global_scope) { + LV_LL_READ(&global_scope->const_ll, c) { + if(lv_streq(c->name, value_clean)) { + value = c->value; + const_found = true; + break; + } + } + } + } + if(!const_found) { + LV_LOG_WARN("Constant `%s` is not found", value_clean); + continue; + } } if(lv_streq(value, "remove")) { diff --git a/tests/src/test_assets/xml/view2.xml b/tests/src/test_assets/xml/view2.xml index 117b41c9ba..c4a5cb2431 100644 --- a/tests/src/test_assets/xml/view2.xml +++ b/tests/src/test_assets/xml/view2.xml @@ -9,7 +9,7 @@