mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
fix(obj): fix crash of lv_obj_move_foreground/background when the parent of obj is NULL (#3577)
* fix(obj): fix crash of lv_obj_move_foreground/background when the parent of obj is NULL * decrease LOG level Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
parent
778d872409
commit
bb7feb232f
@ -191,14 +191,19 @@ void lv_obj_move_to_index(lv_obj_t * obj, int32_t index)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
|
||||
if(!parent) {
|
||||
LV_LOG_WARN("parent is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
if(index < 0) {
|
||||
index = lv_obj_get_child_cnt(lv_obj_get_parent(obj)) + index;
|
||||
index = lv_obj_get_child_cnt(parent) + index;
|
||||
}
|
||||
|
||||
const int32_t old_index = lv_obj_get_index(obj);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
|
||||
if(index < 0) return;
|
||||
if(index >= (int32_t) lv_obj_get_child_cnt(parent)) return;
|
||||
if(index == old_index) return;
|
||||
|
@ -55,6 +55,11 @@ static inline LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_task_handler(void)
|
||||
static inline void lv_obj_move_foreground(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(!parent) {
|
||||
LV_LOG_WARN("parent is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_move_to_index(obj, lv_obj_get_child_cnt(parent) - 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user