Skip to content

Commit eab16d2

Browse files
committed
improve theme_default_foreach
1 parent 4ed1be0 commit eab16d2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* 补充统一foreach visit返回值处理逻辑(感谢兆坤提供补丁)
88
* improve darray_foreach.diff(感谢兆坤提供补丁)
99
* 补充style_mutable 统一foreach visit返回值处理逻辑(感谢兆坤提供补丁)
10+
* 补充theme_default 统一foreach visit返回值处理逻辑(感谢兆坤提供补丁)
1011

1112

1213
2025/08/23

src/base/theme_default.inc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static const uint8_t* theme_default_find_style(theme_t* theme, const char* widge
5151
}
5252

5353
static ret_t theme_default_foreach(theme_t* theme, theme_on_data_t on_data, void* ctx) {
54+
ret_t ret = RET_OK;
5455
uint32_t i = 0;
5556
const theme_item_t* iter = NULL;
5657
const theme_header_t* header = NULL;
@@ -60,15 +61,15 @@ static ret_t theme_default_foreach(theme_t* theme, theme_on_data_t on_data, void
6061
header = (const theme_header_t*)(theme->data);
6162
iter = (const theme_item_t*)(theme->data + sizeof(theme_header_t));
6263

63-
for (i = 0; i < header->nr; i++) {
64+
for (i = 0; i < header->nr; i++, iter++) {
6465
const uint8_t* data = theme->data + iter->offset;
65-
if (on_data(ctx, iter->widget_type, iter->name, iter->state, data) == RET_STOP) {
66-
break;
67-
}
68-
iter++;
66+
67+
ret = on_data(ctx, iter->widget_type, iter->name, iter->state, data);
68+
TK_FOREACH_VISIT_RESULT_PROCESSING(
69+
ret, log_warn("%s: result type REMOVE is not supported!\n", __FUNCTION__));
6970
}
7071

71-
return RET_OK;
72+
return ret;
7273
}
7374

7475
theme_t* theme_default_create_ex(const uint8_t* data, bool_t need_free_data) {

0 commit comments

Comments
 (0)