fix xml_theme_gen

This commit is contained in:
lixianjing 2020-12-05 08:10:11 +08:00
parent e0d8e2419b
commit 887cfbc458
2 changed files with 18 additions and 8 deletions

View File

@ -1,5 +1,8 @@
# 最新动态 # 最新动态
2020/12/05
* 修复theme\_gen可能存在没有初始化变量的问题感谢朝泽提供补丁
2020/12/04 2020/12/04
* fscript 支持注册全局函数。 * fscript 支持注册全局函数。

View File

@ -199,9 +199,7 @@ static void xml_gen_on_text(XmlBuilder* thiz, const char* text, size_t length) {
xml_builder_t* b = (xml_builder_t*)thiz; xml_builder_t* b = (xml_builder_t*)thiz;
if (b->is_property) { if (b->is_property) {
Style* s; Style* s = NULL;
value_t v;
ENSURE(style_normalize_value(b->property_name, text, &v) == RET_OK);
if (b->level == 1) { if (b->level == 1) {
s = &(b->widget_style); s = &(b->widget_style);
@ -211,12 +209,17 @@ static void xml_gen_on_text(XmlBuilder* thiz, const char* text, size_t length) {
s = &(b->state_style); s = &(b->state_style);
} }
if (v.type == VALUE_TYPE_STRING) { if (s != NULL) {
s->AddString(b->property_name, value_str(&v)); value_t v;
} else { ENSURE(style_normalize_value(b->property_name, text, &v) == RET_OK);
s->AddInt(b->property_name, value_int(&v));
if (v.type == VALUE_TYPE_STRING) {
s->AddString(b->property_name, value_str(&v));
} else {
s->AddInt(b->property_name, value_int(&v));
}
value_reset(&v);
} }
value_reset(&v);
} }
return; return;
@ -267,6 +270,8 @@ uint32_t xml_gen_buff(const char* xml, uint8_t* output, uint32_t max_size) {
xml_builder_t b; xml_builder_t b;
return_value_if_fail(xml != NULL && output != NULL, 0); return_value_if_fail(xml != NULL && output != NULL, 0);
memset(&b, 0x00, sizeof(b));
XmlParser* parser = xml_parser_create(); XmlParser* parser = xml_parser_create();
xml_parser_set_builder(parser, builder_init(b)); xml_parser_set_builder(parser, builder_init(b));
xml_parser_parse(parser, xml, strlen(xml)); xml_parser_parse(parser, xml, strlen(xml));
@ -288,6 +293,8 @@ bool xml_gen(const char* input_file, const char* output_file, const char* theme,
wbuffer_t wbuffer; wbuffer_t wbuffer;
return_value_if_fail(input_file != NULL && output_file != NULL, false); return_value_if_fail(input_file != NULL && output_file != NULL, false);
memset(&b, 0x00, sizeof(b));
wbuffer_init_extendable(&wbuffer); wbuffer_init_extendable(&wbuffer);
XmlParser* parser = xml_parser_create(); XmlParser* parser = xml_parser_create();
xml_parser_set_builder(parser, builder_init(b)); xml_parser_set_builder(parser, builder_init(b));