From 5c984b4a5364b6455966eb3a860153806c51626f Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Thu, 31 Aug 2023 03:55:29 +0800 Subject: [PATCH] fix(layout): wrong layout counter (#4501) --- src/layouts/lv_layout.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/layouts/lv_layout.c b/src/layouts/lv_layout.c index a62985758..50674ebe9 100644 --- a/src/layouts/lv_layout.c +++ b/src/layouts/lv_layout.c @@ -52,13 +52,12 @@ void _lv_layout_init(void) uint32_t lv_layout_register(lv_layout_update_cb_t cb, void * user_data) { - layout_cnt++; - layout_list_def = lv_realloc(layout_list_def, layout_cnt * sizeof(lv_layout_dsc_t)); + layout_list_def = lv_realloc(layout_list_def, (layout_cnt + 1) * sizeof(lv_layout_dsc_t)); LV_ASSERT_MALLOC(layout_list_def); - layout_list_def[layout_cnt - 1].cb = cb; - layout_list_def[layout_cnt - 1].user_data = user_data; - return layout_cnt; /*No -1 to skip 0th index*/ + layout_list_def[layout_cnt].cb = cb; + layout_list_def[layout_cnt].user_data = user_data; + return layout_cnt++; } void _lv_layout_apply(lv_obj_t * obj)