What do you want to achieve?
I’d like widget pointers for widgets on a temporary screen to be reset to NULL when the screen is deleted.
Do you see alternative options and workaround to achieve it?
I do not.
Mention some use cases
If an event handler needs to refer to a widget other than the one that triggered the event, it would be useful to be able to use the ui widget pointer global variable(lv_obj_t*) after checking for NULL and lv_obj_is_valid(), but without setting the pointer variables to NULL on screen deletion, it is unsafe.
Currently, the *_screen_init() function allocates and assigns each global widget pointer variable. However, all temporary pages are destroyed with scr_unloaded_delete_cb(), which deletes the object tree for the screen, but does not reset the widget pointers to NULL. Rarely, a dangling widget pointer will point to a newly allocated object, so that lv_obj_is_valid() returns true even after the corresponding screen has been deleted.
Please see Lv_obj_is_valid() doesn't work 100% of the time - #2 by kisvegabor - General discussion - LVGL Forum