Hello!
I’m trying to understand how to clear a widget from memory.
It’s my understanding you can’t really destroy them but once removed from the parent then the trash collector will get rid of it.
I have two circumstances i’ve been testing with
-
I make a button that creates a widget of a class that is just a child class of user widget. the widget will self remove from parent on a button press. I can click the button to create a bunch and then hit the button to remove from parent on all of them. All the widget objects removed from the viewport in but looking at the debug drop down, it always keeps the most recently created object even after manually calling the trash collector. If i then create more and then close them, it will still always keep the most recently created one.
-
I push a button the calls a function and passes a reference widget class. The reference widget class is a child class of an another widget class. In the function i create the object and add it to the view port and adjust the size and position. i then have a different button which gets all widgets of the parent class, and with a for loop removes them all from parent. so i can create a bunch and then with one button remove them all from parent. they do disappear from the viewport but i can still seem them in the debug drop down. Running the trash collector does nothing.
I don’t really understand either behavior. i have two different circumstances, neither acting how i expect. I obviously am missing some fundamental knowledge.
I found some old threads about this being a bug but it seems like thats resolved.
I could work around it but since I think the root of this is a case of me not understanding references well enough, i’m hoping to get some advise before moving on.