fix(obj_tree): fix unintended click triggers on object deletion (#5907)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
VIFEXT 2024-03-20 10:11:59 +08:00 committed by GitHub
parent 3c8ef96213
commit ee26f1df29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -484,6 +484,15 @@ static void lv_obj_delete_async_cb(void * obj)
lv_obj_delete(obj);
}
static void obj_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
{
/*Wait for release to avoid accidentally triggering other obj to be clicked*/
lv_indev_wait_release(indev);
/*Reset the input device*/
lv_indev_reset(indev, obj);
}
static void obj_delete_core(lv_obj_t * obj)
{
if(obj->is_deleting)
@ -516,7 +525,7 @@ static void obj_delete_core(lv_obj_t * obj)
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_POINTER || indev_type == LV_INDEV_TYPE_BUTTON) {
if(indev->pointer.act_obj == obj || indev->pointer.last_obj == obj || indev->pointer.scroll_obj == obj) {
lv_indev_reset(indev, obj);
obj_indev_reset(indev, obj);
}
if(indev->pointer.last_pressed == obj) {
indev->pointer.last_pressed = NULL;
@ -524,7 +533,7 @@ static void obj_delete_core(lv_obj_t * obj)
}
if(indev->group == group && obj == lv_indev_get_active_obj()) {
lv_indev_reset(indev, obj);
obj_indev_reset(indev, obj);
}
indev = lv_indev_get_next(indev);
}

View File

@ -422,6 +422,8 @@ void test_observer_arc_value(void)
lv_obj_update_layout(obj);
lv_test_mouse_release();
lv_test_indev_wait(100);
lv_test_mouse_move_to(65, 10);
lv_test_mouse_press();
lv_test_indev_wait(100);
@ -446,9 +448,12 @@ void test_observer_slider_value(void)
lv_obj_update_layout(obj);
lv_test_mouse_release();
lv_test_indev_wait(100);
lv_test_mouse_move_to(65, 10);
lv_test_mouse_press();
lv_test_indev_wait(100);
lv_test_mouse_move_to(75, 10);
lv_test_mouse_press();
lv_test_indev_wait(100);