lv_obj_is_valid
can fail in very rare cases. Let’s say lv_obj_t * scr1_obj1
points to a valid object. You delete it and start to create new widgets. It can happen that a new widget is allocated to the very same address which is pointed by scr1_obj1
. So scr1_obj1
by accident will point to a valid widget.
I think we can not do anything to prevent it and detect these cases. Setting scr1_obj1 = NULL
when it’s deleted is definitely the recommended practice.