1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(object_tree): make lv_obj_get_index return error value if the object has no parent (#4152)

This commit is contained in:
sparkles43 2023-04-21 11:40:13 +02:00 committed by GitHub
parent 312303cb44
commit 78645a5967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -339,7 +339,7 @@ uint32_t lv_obj_get_index(const lv_obj_t * obj)
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent == NULL) return 0;
if(parent == NULL) return 0xFFFFFFFF;
uint32_t i = 0;
for(i = 0; i < lv_obj_get_child_cnt(parent); i++) {

View File

@ -151,7 +151,8 @@ uint32_t lv_obj_get_child_cnt(const struct _lv_obj_t * obj);
* Get the index of a child.
* @param obj pointer to an object
* @return the child index of the object.
* E.g. 0: the oldest (firstly created child)
* E.g. 0: the oldest (firstly created child).
* (0xFFFFFFFF if child could not be found or no parent exists)
*/
uint32_t lv_obj_get_index(const struct _lv_obj_t * obj);