improve object_default

This commit is contained in:
lixianjing 2024-08-01 17:57:28 +08:00
parent 55a1ad1183
commit 568aaec80e
3 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,6 @@
# 最新动态
2024/08/1
* 修复了object_default读写 "[a]" 这样的属性名会出错的问题(感谢陈聪提供补丁)
2024/07/31
* 修改app_helper没有从compile config中获取LCD_ORIENTATION的问题(感谢朝泽提供补丁)

View File

@ -45,7 +45,7 @@ static value_t* object_default_find_prop_by_name(tk_object_t* obj, const char* n
object_default_t* o = OBJECT_DEFAULT(obj);
return_value_if_fail(o != NULL && name != NULL, NULL);
if (*name == '[') {
if (*name == '[' && tk_isdigit(name[1]) && tk_str_end_with(name, "]")) {
uint32_t index = tk_atoi(name + 1);
return_value_if_fail(index < o->props.size, NULL);
nv = (named_value_t*)(o->props.elms[index]);

View File

@ -511,6 +511,7 @@ TEST(ObjectDefault, size) {
ASSERT_STREQ(tk_object_get_prop_str(obj, "[0]"), "123");
ASSERT_STREQ(tk_object_get_prop_str(obj, "[1]"), "abc");
ASSERT_STREQ(tk_object_get_prop_str(obj, "[a]"), NULL);
tk_object_unref(obj);
}