Description
Currently we provide no way to delete a Screen
after it's been instantiated. Having the user manually call a deletion function also feels... un-rusty and generally unwise as it would be easy to forget. Also, making the screen be deleted on Drop
carries the risk of e.g. a user calling get_scr_act()
multiple times and double-deleting a screen -> a double free -> undefined behaviour. I'm honestly kind of stumped as to what to do here; we can't store some kind of is_active: bool
field either as every call to get_scr_act()
returns a different Screen
and there's no way to dynamically check on drop if there are other Screen
s pointing to the same underlying object.
The other option is to have the Display
store a copy of a pointer to the last Screen
it returned and simply refuse to return multiple identical Screen
s thus allowing us to delete on drop, but this does make things slightly more inconvenient (and can be trivially circumvented by changing the Screen
and then going back, unless we store a collection).
Also, how do we prevent accessing child objects of a Screen
(or any object) and thus a use-after-free post-deletion?