mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-27 19:53:42 +08:00
fix(indev): fix use after free of last hovered object (#6405)
This commit is contained in:
parent
2d7a9ac232
commit
eff59f7bba
@ -537,6 +537,9 @@ static void obj_delete_core(lv_obj_t * obj)
|
||||
if(indev->pointer.last_pressed == obj) {
|
||||
indev->pointer.last_pressed = NULL;
|
||||
}
|
||||
if(indev->pointer.last_hovered == obj) {
|
||||
indev->pointer.last_hovered = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(indev->group == group && obj == lv_indev_get_active_obj()) {
|
||||
|
@ -81,14 +81,16 @@ void test_hover_basic(void)
|
||||
|
||||
void test_hover_delete(void)
|
||||
{
|
||||
lv_obj_t * button = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(button, 200, 100);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(btn, 200, 100);
|
||||
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_move_to(50, 50);
|
||||
lv_test_indev_wait(50);
|
||||
lv_obj_delete(button); /*No crash while deleting the hovered button*/
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_move_to(i * 10, 50);
|
||||
lv_test_indev_wait(50);
|
||||
|
||||
lv_obj_delete(btn); /*No crash while deleting the hovered button*/
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user