Delete types?
BlitzMax Forums/BlitzMax Programming/Delete types?
| ||
I'm having a brain fart - What would be the best way to clear out instances of a type? I need to toss out a bunch of types created in my main loop when a new game is started. |
| ||
Set the variables holding them to Null, or overwrite the variables with new values, perhaps? Eventually, they will be garbage-collected. |
| ||
That's what I thought. I'll have another look at my stuff, something must be seriously wrong. |
| ||
If you've added objects to a TList (for example), you need to remove them from there, too, i.e. TList.Remove(). Or just Null/Clear the list. GC will only clean up the object when it isn't being referenced any more. |
| ||
Yeah, I added these objects to a list.What I have is a type that defines a list of items that I show on the screen. I am using FryGUI and one of the type fields is a fry_TLabel. So when I create a list of items to show I create a bunch of fry_TLabels. I am doing this because I hacked together some functions that allow me do animate lables, buttons etc and using types to contain everything makes it easier. Anyway I need to "clear out" the list of items from time to time and recreate them but the fry_TLables don't want to go away. Even if I do something simple like this: Local endlabel:fry_TLabel = fry_CreateLabel("someLabel", "Hello World", 350, 350, 600, 20, 1, 1, endpanel) then somewhere else do this: endlabel = null the label is still visible on the screen. |
| ||
the function or method 'fry_CreateLabel' probably adds the label to a list or array in the FRYGUI module so you would have to call some FRYGUI function to destroy the label probably |
| ||
I took a quick look and there isn't a function to destroy the label as far as I can tell. I may try and add one. |
| ||
What about some comands like FreeGadget() or DeleteGadget()? Afaik FryGUI has those. |